Closed Bug 1194525 Opened 9 years ago Closed 9 years ago

Gecko should ignore |postResult| calls for WebActivities with no returnValue

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla45
blocking-b2g 2.5+
Tracking Status
firefox45 --- fixed
b2g-v2.2 --- affected
b2g-v2.5 --- fixed
b2g-master --- affected

People

(Reporter: dietrich, Assigned: anatal)

References

Details

(Keywords: dev-doc-complete, foxfood, Whiteboard: [bzlite],permafail)

Attachments

(3 files, 7 obsolete files)

User-Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0

Twitter shows up and then immediately disappears, putting me back in gallery.
QA Whiteboard: [foxfood-triage]
Keywords: verifyme
Hi Mahendra,

    When sharing the image from Gallery to Twitter on the latest Flame KK v2.2&2.5 and Aries KK v2.5, the Twitter app shows up and doesn't disappear, but it stays in the twitter app and doesn't switch to a new tweet, user can't share the image that user selected from Gallery, unless user create a new tweet and select the image from Gallery again. This problem are different from the above mentioned in comment 0. 
    Could you help to check this problem again? 

Thank you very much.


STR:
1.Sign in Twitter account (On Flame v2.2&2.5, you need to download the Twitter app).
2.Open Gallery app and select an image.
3.Tap "Share" icon and select "Twitter".
Actual results: The Twitter app shows up and doesn't disappear, but it stays in the twitter app and doesn't switch to a new tweet, then user can't share the image. 

Please see attachments: AriesKK_v2.5.3gp and logcat_1142.txt
Reproduce rate: 10/10


------------------------------------------------------------------------------------------
Device: Flame KK 2.2 (Affected) 
Build ID               20150817032503
Gaia Revision          335cd8e79c20f8d8e93a6efc9b97cc0ec17b5a46
Gaia Date              2015-08-14 19:06:41
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g37_v2_2/rev/82ec88fa015c
Gecko Version          37.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150817.065716
Firmware Date          Mon Aug 17 06:57:27 EDT 2015
Firmware Version       v18D v4
Bootloader             L1TC000118D0

Device: Flame KK 2.5 (Affected)
Build ID               20150817150206
Gaia Revision          60489c1ff8c5d1633fc4837d4f8019623d4e1940
Gaia Date              2015-08-16 02:21:48
Gecko Revision         https://hg.mozilla.org/mozilla-
central/rev/9673c75864beafca2f6c8b117b98503128bf2e56
Gecko Version          43.0a1
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150817.182933
Firmware Date          Mon Aug 17 18:29:45 EDT 2015
Firmware Version       v18D v4
Bootloader             L1TC000118D0

Device: Aries KK 2.5(Affected)
Build ID               20150818005621
Gaia Revision          60489c1ff8c5d1633fc4837d4f8019623d4e1940
Gaia Date              2015-08-16 02:21:48
Gecko Revision         https://hg.mozilla.org/mozilla-
central/rev/6ae3e9ff53b2bae8d95a90c9f25368fd81fa357e
Gecko Version          43.0a1
Device Name            aries
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.worker.20150818.003312
Firmware Date          Tue Aug 18 00:33:21 UTC 2015
Bootloader             s1
QA Whiteboard: [foxfood-triage] → [foxfood-triage][MGSEI-Triage+]
Flags: needinfo?(mpotharaju)
Keywords: verifyme
Thanks for the verification and STR Shally. Will ask someone from Gallery team to take a look and find a right owner.
Component: Gaia::Feedback → Gaia::Gallery
Flags: needinfo?(mpotharaju)
I don't think it's the gallery app's problem per se, but could be related to the pick activity.  I remember we had a similar issue with the twitter share a while ago.  Ni?ing djf in case he can remember what kind of issue it was, and which component we can direct this bug to.
Flags: needinfo?(dflanagan)
No-Jun: I don't remember any similar bug with Twitter. We've got the same share activity bug with the Facebook app.  And we've had OOM-related bugs for activities involving photos before, but this one is not ringing any bells.

No one seems to be saying that this is a regression, are they? If this has ever worked in the past, then let me know and I'll investigate. Similarly, if you can share a photo directly from the camera to Twitter, then that would indicate that it is my bug in Gallery to fix.

Please also check whether the share activity works for small images (not photos from the camera). If so, then maybe there is a problem in our platform.

But if it has never worked, then this sounds like it is a Tech Evangelism bug, like the Facebook one. We should ask Twitter to either make the share activity work, or modify their manifest so that it does not advertise the ability to accept shared images.
Flags: needinfo?(dflanagan)
I think the feature has worked in the past at some point: the resolution of bug 823762 seems to say the feature was added and verified.  I also found the bug I was pondering about, which is bug 983544 (still open for some reason)   

So... I think based on those, this is a regression bug.


Adding qawanted to test this with a small image (let's say, a 128 by 128 image)
Keywords: qawanted
Keywords: regression
Yes, absolutely a regression. I used this regularly and it worked fine. That doesn't rule out it being a tech evangelism bug though. Twitter's share activity disappeared altogether for a few days last week.

Or it could be something similar to bug 1192703.
I think people are talking about different bugs here. The issue at comment 0 looks like bug 1192703, and the issue at comment 1 I recall it being a very old bug and has never been fixed (if it was fixed at some point then I didn't know about) - example bug 1003301.
Correct, the scenario in comment #1 is not what I reported for this bug.

Bug 1192703, also reported by me, is now fixed. But it did not fix this bug. I mentioned it because it seems similar.
I can reproduce this on the Aires 2.5 and Flame 2.5. I've tested that also with a small image (128x128 px) and got the same result. Twitter opens and then immediately closes, user returns back to the gallery.Please check the video https://youtu.be/jo-ByfCmo1M

Environmental Variables:
Device: Aries 2.5
Build ID: 20150812231434
Gaia: 52f3ea58df38e5427f6afeb636bc6ad01d24022f
Gecko: 7649ffe28b67aa2dad0f67ea01500c0ff91b2bac
Gonk: 2916e2368074b5383c80bf5a0fba3fc83ba310bd
Version: 43.0a1 (2.5)
Firmware Version: D5803_23.1.A.1.28_NCB.ftf
User Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0

Device: Flame 2.5
Build ID: 20150903041524
Gaia: a55d3d512a765bd483bd595b0c8f80c5f1d61b65
Gecko: 74fbd245369c474beaa7f2b1959570243e3dafaa
Gonk: c4779d6da0f85894b1f78f0351b43f2949e8decd
Version: 43.0a1 (2.5)
Firmware Version: v18D
User Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0
Flags: needinfo?(jmercado)
I can't reproduce this on Flame 2.2

Device: Flame 2.2
Build ID: 20150901123002
Gaia: 335cd8e79c20f8d8e93a6efc9b97cc0ec17b5a46
Gecko: c03e2bc6a3a4
Gonk: bd9cb3af2a0354577a6903917bc826489050b40d
Version: 37.0 (2.2)
Firmware Version: v18D
User Agent: Mozilla/5.0 (Mobile; rv:37.0) Gecko/37.0 Firefox/37.0
QA Whiteboard: [foxfood-triage][MGSEI-Triage+] → [foxfood-triage][MGSEI-Triage+][QAnalyst-Triage?]
Keywords: qawanted
Let's get a window on this issue since it wasn't occuring in 2.2.
Flags: needinfo?(jmercado)
QA Contact: mshuman
I am able to reproduce this issue on Flame 2.5, 2.2, 2.1, and 2.0 builds.
When attempting to share an image from the Gallery to Twitter, the Twitter app will open, then the user will be returned to the Gallery app.

Note: On more recent 2.5 builds, this issue will also close out the Twitter app, but on earlier builds, the Twitter app will remain open in Card View, and be running in the background. Regardless, the improper behavior appears the same to the user.

Removing the regression and regressionwindow-wanted tags.

Environmental Variables:
Device: Flame 2.5
BuildID: 20150908030224
Gaia: 891798f1e345bc2b69e71de42bd524a90b1745c4
Gecko: 5fe9ed3edd6811a662d40d05e37b0d66e9520d82
Gonk: c4779d6da0f85894b1f78f0351b43f2949e8decd
Version: 43.0a1 (Master)
Firmware Version: v18D
User Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0

Environmental Variables:
Device: Flame 2.2
BuildID: 20150908032505
Gaia: 335cd8e79c20f8d8e93a6efc9b97cc0ec17b5a46
Gecko: 96170c571381
Gonk: bd9cb3af2a0354577a6903917bc826489050b40d
Version: 37.0 (2.2)
Firmware Version: v18D
User Agent: Mozilla/5.0 (Mobile; rv:37.0) Gecko/37.0 Firefox/37.0

Environmental Variables:
Device: Flame 2.1
BuildID: 20150724001207
Gaia: 9dba58d18006e921546cec62c76074ce81e16518
Gecko: 41e10c6740be
Gonk: bd9cb3af2a0354577a6903917bc826489050b40d
Version: 34.0 (2.1)
Firmware Version: v18D
User Agent: Mozilla/5.0 (Mobile; rv:34.0) Gecko/34.0 Firefox/34.0

Environmental Variables:
Device: Flame 2.0
BuildID: 20150723000207
Gaia: b16ba05481e577bc644ed8966f587a70fe2148e6
Gecko: 2e6f1d4deff9
Gonk: 040bb1e9ac8a5b6dd756fdd696aa37a8868b5c67
Version: 32.0 (2.0)
Firmware Version: v18D
User Agent: Mozilla/5.0 (Mobile; rv:32.0) Gecko/32.0 Firefox/32.0
Flags: needinfo?(jmercado)
QA Whiteboard: [foxfood-triage][MGSEI-Triage+][QAnalyst-Triage?] → [foxfood-triage][MGSEI-Triage+][QAnalyst-Triage+]
Flags: needinfo?(jmercado)
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
FWIW it works for me on the current dogfood build so I doubt it's bug 1049465.

However I get bug 1192703: the Twitter app goes to background and the Gallery app is foreground. However if I switch to the Twitter app, the image is ready to be shared.

Reopening.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
[Blocking Requested - why for this release]:
blocking-b2g: --- → 2.5?
blocking-b2g: 2.5? → 2.5+
Priority: -- → P3
Taking this to investigate
Assignee: nobody → dflanagan
I see exactly what Dietrich reports in comment 0, using a Flame with a nightly build from a couple of days ago.  However, I also notice that the shared image does get transferred to the twitter app... I share the image, see twitter come up, and then I get taken right back to gallery.  But if I long press on the home button and go back into twitter, I am in the compose new tweet screen, and the image I shared is there, too.

Here's what I think is happening: the twitter app receives the share activity, gets the image blob, and then navigates from https://mobile.twitter.com to https://mobile.twitter.com/compose/tweet. I think the system app is seeing that navigation and assuming it means that the activity has failed and so is taking us back to the gallery app.

I see the same behavior when I share a photo from Camera to Twitter, so this is not a Gallery-specific bug. And since Twitter does receive and display the shared image, I think it is not a Twitter bug.  So I think this must be a System app bug.

Tim: in the past, I would have asked Alive to investigate this. Is there someone on your team who can take it?
Assignee: dflanagan → nobody
Component: Gaia::Gallery → Gaia::System::Window Mgmt
Flags: needinfo?(timdream)
I wonder if this regression was caused by bug 1192489 or bug 1190775?
Nope. I tried backing both of those out and the bug still occurs. I think we need professional help finding a regression window here.

In comment 8, Dietrich says it is a regression. In comment 14, Marty says it is not a regression and always occurs.  Maybe we're looking at two different bugs.

I think this is a regression and we need to find the window.
At one point this bug was marked as a duplicate of bug 1049465. They are not dupes. In that one, it looks like twitter opens up but does not display the image. In this one, twitter opens and displays the image, but then the user gets sent back to the gallery app. So when looking for a regression window, please keep the two separate.
There won't be a regression window if your comment 19 is correct. Twitter app is responsible of keeping on the current page (and the MozActivityRequestHandler instance) so that it could do handler.postResult() and complete the flow. When the instance is assumed lost Gecko assumes the activity handling has failed.

https://developer.mozilla.org/en-US/docs/Web/API/MozActivityRequestHandler

Unless my recollection on how "share" activity should work is wrong, and we don't ask inline activity apps for a response. If that's the case I don't really know when we *should* close the activity and *should not*.

It's sad that there is no documentation on these proprietary APIs, and sadder to keep using it 3 years after FxOS 1.0.
Flags: needinfo?(timdream)
(In reply to David Flanagan [:djf] from comment #19)
> Here's what I think is happening: the twitter app receives the share
> activity, gets the image blob, and then navigates from
> https://mobile.twitter.com to https://mobile.twitter.com/compose/tweet.

Do you know if it is a real navigation or maybe a pushState call ?
(In reply to Julien Wajsberg [:julienw] (away Oct 1st, 2nd) from comment #24)
> (In reply to David Flanagan [:djf] from comment #19)
> > Here's what I think is happening: the twitter app receives the share
> > activity, gets the image blob, and then navigates from
> > https://mobile.twitter.com to https://mobile.twitter.com/compose/tweet.
> 
> Do you know if it is a real navigation or maybe a pushState call ?

I don't think the issue comes from the navigation anyway.

The Twitter app declares a share (disposition:window) activity with no returnValue but still does a |postResult('ok')|.

The postResult call triggers a mozbrowseractivitydone event, which triggers the transition back to the gallery app [1].

I doubt we'll get Twitter to do the fix but maybe gecko could ignore |postResult| calls when the activity has no returnValue?


[1] https://github.com/mozilla-b2g/gaia/blob/7507a12360ed14203b49c70c69e8b3950236c4f6/apps/system/js/app_window.js#L1010-L1013
There's no regression window to be found here.  We were able to reproduce this issue on all branches that we still make builds for in comment 14.
NI-ing Fabrice re Comment 25.
Flags: needinfo?(fabrice)
(In reply to Etienne Segonzac (:etienne) from comment #28)
> NI-ing Fabrice re Comment 25.

Sure, we can do that. Either rename this bug or file a new one.
Flags: needinfo?(fabrice)
Component: Gaia::System::Window Mgmt → DOM
Product: Firefox OS → Core
Summary: share image from gallery to twitter fails → Gecko should ignore |postResult| calls for WebActivities with no returnValue
Whiteboard: [bzlite] → [bzlite][platform]
Whiteboard: [bzlite][platform] → [bzlite][platform], permafail
Hi Etienne, Will you take this bug?
Flags: needinfo?(etienne)
Whiteboard: [bzlite][platform], permafail → [bzlite],permafail
(In reply to Ken Chang[:ken] from comment #30)
> Hi Etienne, Will you take this bug?

Since I don't know anything about the gecko-side of the WebActivities implementation I hope not :)
Flags: needinfo?(etienne)
I can take this (I think ;) as part of our v2.5 blocker-fest, but if someone else would rather take it on, feel free to steal (promptly)!
Assignee: nobody → bugmail
Status: REOPENED → ASSIGNED
Assignee: bugmail → anatal
(In reply to Andrew Sutherland [:asuth] from comment #32)
> I can take this (I think ;) as part of our v2.5 blocker-fest, but if someone
> else would rather take it on, feel free to steal (promptly)!

Ok Andrew, I can take care of it!
(In reply to Andre Natal from comment #33)
> Ok Andrew, I can take care of it!

Cool.  So I think the fundamental issue is that ActivityWrapper does this no matter what:
  Services.obs.notifyObservers(docshell, "activity-done", aTopic);
Which BrowserElementChildPreload.js consumes and propagates it as "activitydone" to BrowserElementParent.js which in turn propagates it as a mozbrowser event per comment 25.

The simplest fix is that ActivityWrapper can conditionalize that statement by doing something like "if (aMessage.target.returnValue)".  It seems a bit sketchy to me, but I think it satisfies comment 25 and comment 29.
Andre, Is this in progress with a fix?

Thanks
(In reply to Mahendra Potharaju [:mahe] from comment #35)
> Andre, Is this in progress with a fix?
> 
> Thanks

Yes, it is. Will submit it today.
Comment on attachment 8679958 [details] [diff] [review]
This patch contains the gecko part of the fix.

Review of attachment 8679958 [details] [diff] [review]:
-----------------------------------------------------------------

I'd rather block postResult() from doing anything instead. Look if you can enforce that in https://mxr.mozilla.org/mozilla-central/source/dom/activities/ActivityRequestHandler.js#51

Also, we will need tests. There are some to get started in https://mxr.mozilla.org/mozilla-central/source/dom/activities/tests/mochi/
Attachment #8679958 - Flags: review?(fabrice) → review-
Attachment #8679958 - Attachment is obsolete: true
Attachment #8680564 - Flags: review?(fabrice)
(In reply to [:fabrice] Fabrice Desré from comment #39)

> 
> I'd rather block postResult() from doing anything instead. Look if you can
> enforce that in
> https://mxr.mozilla.org/mozilla-central/source/dom/activities/
> ActivityRequestHandler.js#51
>

Fabrice, 

I couldn't find a way to access the returnValue in ActivityRequestHandler.js. 'aResult' from postResult can't be used, since is always filled in this particular situation we want to avoid with this bug [1].

In the tests I did, I realized the 'data' field of the payload that is carried in the message from ActivityWrapper is always 'null' no matter what. So I found less invasive simple include the returnValue there [2] and check it on ActivityRequestHandler [3] to then decide if we shall send or not the 'Activity:PostResult' message back.

That way we don't need to change the webidl to accommodate it. Another possibility is try to get the whole message by the id here [4], but I don't know if this is possible.

Here is the try for the new patch [5]

[1]
https://github.com/andrenatal/gecko-dev-speech/commit/b2e4723013989f07920663d2358fa414a41135cb#diff-3d4f1e7212797e921b15f76110cddf93L51

[2]
https://github.com/andrenatal/gecko-dev-speech/commit/b2e4723013989f07920663d2358fa414a41135cb#diff-00d7a0a493ef78c5fc41a6dbd70c63f0R43 

[3] https://github.com/andrenatal/gecko-dev-speech/commit/b2e4723013989f07920663d2358fa414a41135cb#diff-3d4f1e7212797e921b15f76110cddf93R52

[4] https://github.com/andrenatal/gecko-dev-speech/blob/b2e4723013989f07920663d2358fa414a41135cb/dom/activities/ActivityRequestHandler.js#L40
    
[5] https://treeherder.mozilla.org/#/jobs?repo=try&revision=8e8ca2fce262
 
> Also, we will need tests. There are some to get started in
> https://mxr.mozilla.org/mozilla-central/source/dom/activities/tests/mochi/

I wrote a new marionettejs test for it here [6] (or Comment 37) that is both passing with the patch and failing without it as you can see in gaia-try [7]. 

I tried to run these tests you mentioned in 'dom/activities/tests/mochi' with my b2g-desktop build, but I am getting a message saying there are no tests in this folder [8]. I am used to run mochitests for Desktop, but not for b2g, so I am not sure if I need something special. Mochitests from other folders (like dom/svg for example) runs fine.

So the marionettejs ones I already wrote are not enough?


[6] https://github.com/mozilla-b2g/gaia/pull/32805

[7] https://treeherder.mozilla.org/#/jobs?repo=gaia&revision=19b4b93498327487c5f5894929122cd6ad798d56

[8]
mozillas-MacBook-Pro:gecko-b2g-desktop anatal$ ./mach mochitest dom/activities/tests/mochi/
From _tests: Kept 36895 existing; Added/updated 0; Removed 0 files and 0 directories.
The mochitest command could not find any supported tests to run! The
following flavors and subsuites were found, but are either not supported on
b2g_desktop builds, or were excluded on the command line:

    mochitest -f chrome (requires firefox or mulet or b2g or android)

Double check the command line you used, and make sure you are running in
context of the proper build. To switch build contexts, either run |mach|
from the appropriate objdir, or export the correct mozconfig:

    $ export MOZCONFIG=path/to/mozconfig



Thank you very much.
Flags: needinfo?(fabrice)
Comment on attachment 8680564 [details] [diff] [review]
8679958: This patch contains the gecko part of the fix.

Review of attachment 8680564 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/activities/ActivityWrapper.js
@@ +36,5 @@
>      // ActivitiesService will be able to fire an error and complete the
>      // Activity workflow.
>      cpmm.sendAsyncMessage("Activity:Ready", { id: aMessage.id });
>  
> +    // Bug 1194525 - Gecko should ignore |postResult| calls for WebActivities with no returnValue

nit: no need to add the bug number here.

@@ +39,5 @@
>  
> +    // Bug 1194525 - Gecko should ignore |postResult| calls for WebActivities with no returnValue
> +    // We add the return value to the payload to be send to ActivityRequestHandler properly
> +    // decide if should call postResult or not
> +    aMessage.payload.data = { returnValue: aMessage.target.returnValue };

You can't do that, because payload.data may be something else.

@@ +45,1 @@
>      let handler = new aWindow.ActivityRequestHandler(aMessage.id, aMessage.payload);

The clean thing to do is to pass returnValue here as an additional parameter to ActivityRequestHandler
Attachment #8680564 - Flags: review?(fabrice) → review-
I'm running tests usually with a mulet or firefox desktop build. But I'm fine with a marionnette test.
Flags: needinfo?(fabrice)
Attachment #8680861 - Flags: review?(fabrice)
(In reply to [:fabrice] Fabrice Desré from comment #42)
> Comment on attachment 8680564 [details] [diff] [review]
> 8679958: This patch contains the gecko part of the fix.
> 
> Review of attachment 8680564 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/activities/ActivityWrapper.js
> @@ +36,5 @@
> >      // ActivitiesService will be able to fire an error and complete the
> >      // Activity workflow.
> >      cpmm.sendAsyncMessage("Activity:Ready", { id: aMessage.id });
> >  
> > +    // Bug 1194525 - Gecko should ignore |postResult| calls for WebActivities with no returnValue
> 
> nit: no need to add the bug number here.
> 
> @@ +39,5 @@
> >  
> > +    // Bug 1194525 - Gecko should ignore |postResult| calls for WebActivities with no returnValue
> > +    // We add the return value to the payload to be send to ActivityRequestHandler properly
> > +    // decide if should call postResult or not
> > +    aMessage.payload.data = { returnValue: aMessage.target.returnValue };
> 
> You can't do that, because payload.data may be something else.
> 
> @@ +45,1 @@
> >      let handler = new aWindow.ActivityRequestHandler(aMessage.id, aMessage.payload);
> 
> The clean thing to do is to pass returnValue here as an additional parameter
> to ActivityRequestHandler

Thanks Fabrice. I was trying to avoid touching the constructor but actually is better to in this particular case.
Comment on attachment 8680861 [details] [diff] [review]
This patch contains the gecko part of the fix.

Review of attachment 8680861 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with nit addressed

::: dom/activities/ActivityRequestHandler.js
@@ +40,3 @@
>      this._id = aId;
>      this._options = aOptions;
> +    this.returnValue = aReturnValue;

nit: this._returnValue to match the other private members.
Attachment #8680861 - Flags: review?(fabrice) → review+
Comment on attachment 8680861 [details] [diff] [review]
This patch contains the gecko part of the fix.

Jonas, can you r+ the webidl change. We needed to add a parameter to a chrome only constructor.
Attachment #8680861 - Flags: review?(jonas)
Attachment #8680861 - Attachment is obsolete: true
Attachment #8680861 - Flags: review?(jonas)
Attachment #8680876 - Flags: review?(jonas)
(In reply to [:fabrice] Fabrice Desré from comment #47)
> Comment on attachment 8680861 [details] [diff] [review]
> This patch contains the gecko part of the fix.
> 
> Jonas, can you r+ the webidl change. We needed to add a parameter to a
> chrome only constructor.

Thanks Fabrice, just fixed the nit.
Comment on attachment 8680876 [details] [diff] [review]
This patch contains the gecko part of the fix.

Review of attachment 8680876 [details] [diff] [review]:
-----------------------------------------------------------------

Webidl changes look fine.
Attachment #8680876 - Flags: review?(jonas) → review+
Keywords: checkin-needed
Andre,

You need to provide a hg patch and fix the commit message (r=fabrice,sicking)
Keywords: checkin-needed
Attachment #8680876 - Attachment is obsolete: true
(In reply to [:fabrice] Fabrice Desré from comment #51)
> Andre,
> 
> You need to provide a hg patch and fix the commit message (r=fabrice,sicking)

Yes, thanks and sorry about that. Just fixed.
Keywords: checkin-needed
Comment on attachment 8680991 [details]
This patch contains the gecko part of the fix.

Flagging it as the r+ since fabrice and sicking already flagged the obsolete ones.
Attachment #8680991 - Flags: review+
does the Gaia PR also need landing ?
Flags: needinfo?(anatal)
Yes, but just after the gecko patch land in m-c for the test in the pr then be able to pass in gaia-try
Flags: needinfo?(anatal)
So right now, only gecko patch.
In these cases you should rather split up the gaia patch in its own bug.
(In reply to Andre Natal from comment #56)
> Yes, but just after the gecko patch land in m-c for the test in the pr then
> be able to pass in gaia-try

landed the gecko patch
(In reply to Wes Kocher (:KWierso) from comment #61)
> I backed this out in
> https://hg.mozilla.org/integration/mozilla-inbound/rev/b892fb047ebc for
> apparently causing a spike in gij(11/12) failures like
> https://treeherder.mozilla.org/logviewer.html#?job_id=16697770&repo=mozilla-
> inbound

Thank you Wes. 

I am figuring out what was the collateral effect in the ringtone app.
Flags: needinfo?(anatal)
Depends on: 1221358
Blocks: 1221379
Attachment #8679954 - Attachment is obsolete: true
I must confess, I'm somewhat baffled at the decision here. Wasn't there a point where *both* the Twitter app and the Ringtones app worked fine? (This part is unclear, since no one could find a regression window, but I trust Dietrich that it worked at some point.) If this is Twitter's fault, do we know why they changed it? Comment 25 suggests that this is a bug on Twitter's end, but it doesn't seem like anyone's even given them a quick heads-up, on the assumption that they wouldn't care. It's possible that someone has tried pinging them, but I don't see any indication here.

If it's our fault (which seems unlikely from the discussion), shouldn't we try to restore the old logic instead of having activity semantics that require one of the apps to change? I assume the goal is for this API to be standardized at some point, so shouldn't we be clear on the exact semantics here? If this special-casing of the returnValue attribute is something we'd want standardized, I don't have a huge issue with making the change, but otherwise, we should be ensuring that our implementation behaves *correctly*. As bug 1221358 shows, this can break existing apps, and it doesn't seem like we've checked to see if this change would break anyone else.
In any case, we need to protect ourselves against pages that still call postResult() even if they claimed they would not. Blaming the app developer doesn't help the poor user too much... So I still feel this is a worthwhile fix on the gecko side.
I don't understand why you feel it's correct to allow postResult() in this situation.
Providing some context for the ringtones scenario, it was relying on postResult() to trigger the window.close() of its "disposition: inline" activity.  Any app that depends on postResult to trigger window.close() is potentially going to have a bad day.

We could further gate things so that inline activities that call postResult will close, but not windowed activities.  This could make sense because an inline activity by definition cannot/should not stand on its own, but a windowed activity could indeed make sense.
So it seems we have two issues:
1) people calling postResult() when they said they wont.
2) "disposition: inline" activities needing a way to tell us they need to be closed which would not be a side effect of 1) when they are done. But isn't window.close() enough there?
I've always interpreted postResult as orthogonal to the presence of returnValue in the manifest. To me, postResult means "I'm done doing whatever I was doing in the activity", but it doesn't say anything about whether the caller should expect anything to be returned. As Andrew notes, in the Ringtones app, the goal here is for postResult to ultimately close the window, but using postResult is more explicit that the activity is "done". If other browsers implemented the Activity API, the distinction between window.close and activity.postResult may be more important. Personally, I don't have a strong opinion on which one we want to bless, provided we've made a conscious decision.

However, I think the bigger issue is that this is a change in behavior which could negatively affect other apps that do similar things to the Ringtones app. At the *very* least, if we take the attached patch, postResult should log an error (or even better, throw an exception) if returnValue isn't set. The current patch is a silent change in behavior that no one would notice without thorough integration tests.

Still, since I don't see any discussion about this issue with the Twitter folks, I have to assume they don't know it's a problem, and I think it would be wise to at least ask them what they were trying to do before we check in a patch to work around this issue. It could simply be that they didn't understand the semantics of this apparently-undocumented (see comment 23) API.
(In reply to Jim Porter (:squib) from comment #68)
> I've always interpreted postResult as orthogonal to the presence of
> returnValue in the manifest. To me, postResult means "I'm done doing
> whatever I was doing in the activity", but it doesn't say anything about
> whether the caller should expect anything to be returned. As Andrew notes,
> in the Ringtones app, the goal here is for postResult to ultimately close
> the window, but using postResult is more explicit that the activity is
> "done". If other browsers implemented the Activity API, the distinction
> between window.close and activity.postResult may be more important.
> Personally, I don't have a strong opinion on which one we want to bless,
> provided we've made a conscious decision.

I'm not a native speaker so bear with me (and naming is hard), but "postResult" sounds like a pretty straightforward way to say "I'm sending you back something". So I guess we'll have to agree that we disagree in our interpretation there, and that the real issue is that we need to make the API expectations clearer.
Also, there is no effort to try to standardize this api in its current form.

> However, I think the bigger issue is that this is a change in behavior which
> could negatively affect other apps that do similar things to the Ringtones
> app. At the *very* least, if we take the attached patch, postResult should
> log an error (or even better, throw an exception) if returnValue isn't set.
> The current patch is a silent change in behavior that no one would notice
> without thorough integration tests.

I agree with adding a noisy Cu.reportError(...) and throwing. André, can you update your patch?
(In reply to [:fabrice] Fabrice Desré from comment #69)


> I agree with adding a noisy Cu.reportError(...) and throwing. André, can you
> update your patch?

Yes, sure. I agree that throwing an exception here can be useful for the developer. I will update it.
(In reply to [:fabrice] Fabrice Desré from comment #69)
> I'm not a native speaker so bear with me (and naming is hard), but
> "postResult" sounds like a pretty straightforward way to say "I'm sending
> you back something". So I guess we'll have to agree that we disagree in our
> interpretation there, and that the real issue is that we need to make the
> API expectations clearer.

That's fine. I based my interpretation on guesswork, since it's not documented. If postResult is defined to only make sense with returnValue set, that's ok by me (as long as that doesn't cause any other issues).

> Also, there is no effort to try to standardize this api in its current form.

That's disappointing. I thought our goal was to standardize all the Mozilla-specific APIs so that we only used standards-based technologies. That's a whole other set of issues, though.

> I agree with adding a noisy Cu.reportError(...) and throwing. André, can you
> update your patch?

We should probably make sure that throwing a real exception doesn't break Twitter (although part of me smiles at the idea of breaking bad code).
Attachment #8680991 - Attachment is obsolete: true
Attachment #8680991 - Attachment is patch: false
I confirm that with the Cu.reportError() call, both the Ringtone as the Twitter shows the error in the console [1], but only the latter doesn't break, different of the former that requires the landing of Bug 1221358 to avoid breaking.

Here is the try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=6013afafc7c9 


[1] 

E/Twitter ( 2537): [JavaScript Error: "postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp" {file: "jar:file:///system/b2g/omni.ja!/components/ActivityRequestHandler.js" line: 60}]

E/Ringtones( 3044): [JavaScript Error: "postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp" {file: "jar:file:///system/b2g/omni.ja!/components/ActivityRequestHandler.js" line: 60}]
Attachment #8684522 - Flags: review?(fabrice)
FWIW we use postResult in the SMS app as well, with the same expectation that the window will be closed. But I admit we have the expectation because it worked that way, not because it made sense.

Moreover, I see we actually have "returnValue" in our manifest, and I think we added it then because postResult was doing nothing in inline activities without this. So maybe something actually changed how postResult was working without "returnValue" at one point ?
André, did you try also throwing after Cu.reportError() ? If that breaks 3rd party sites too badly we may not do that, but we can fix gaia consumers.
(In reply to [:fabrice] Fabrice Desré from comment #74)
> André, did you try also throwing after Cu.reportError() ? If that breaks 3rd
> party sites too badly we may not do that, but we can fix gaia consumers.

Fabrice, I just tested it with both Cu.reportError() and throw [1], and Twitter handled it but didn't broke. The image was shared and posted correctly [2], despite the errors in console [3].

If you say that's ok, I'll fix the patch and push to try again. 

[1]
    } else {
      Cu.reportError("postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp");
      throw new Error("postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp");
    }


[2] https://twitter.com/andrenatalbr/status/663667547984674816


[3] E/Twitter ( 1826): [JavaScript Error: "postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp" {file: "jar:file:///system/b2g/omni.ja!/components/ActivityRequestHandler.js" line: 60}]
E/Twitter ( 1826): [JavaScript Error: "Error: postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp" {file: "jar:file:///system/b2g/omni.ja!/components/ActivityRequestHandler.js" line: 61}]
E/Twitter ( 1826): [JavaScript Error: "NS_ERROR_UNEXPECTED: " {file: "https://ma.twimg.com/twitter-mobile/15f39f5f185f49a822b85557b539cf2779511d87/assets/m5.js" line: 6}]
(In reply to [:fabrice] Fabrice Desré from comment #74)
> André, did you try also throwing after Cu.reportError() ? If that breaks 3rd
> party sites too badly we may not do that, but we can fix gaia consumers.

And this was the error in Ringtone app:

E/Ringtones( 2891): [JavaScript Error: "postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp" {file: "jar:file:///system/b2g/omni.ja!/components/ActivityRequestHandler.js" line: 60}]
E/Ringtones( 2891): [JavaScript Error: "Error: postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp" {file: "jar:file:///system/b2g/omni.ja!/components/ActivityRequestHandler.js" line: 61}]
E/Ringtones( 2891): [JavaScript Error: "NS_ERROR_UNEXPECTED: " {file: "app://ringtones.gaiamobile.org/js/manage.js" line: 12}]
Updated version of the patch containing the throw.
Attachment #8684522 - Attachment is obsolete: true
Attachment #8684522 - Flags: review?(fabrice)
Attachment #8685147 - Flags: review?(fabrice)
Attachment #8685147 - Flags: review?(fabrice) → review+
Keywords: checkin-needed
Keywords: leave-open
https://hg.mozilla.org/mozilla-central/rev/2433822aeda2
Status: ASSIGNED → RESOLVED
Closed: 9 years ago9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Depends on: 1224395
Hm why isn't this uplifted to the 2.5 branch?
Flags: needinfo?(mpotharaju)
(In reply to Gregor Wagner [:gwagner] from comment #80)
> Hm why isn't this uplifted to the 2.5 branch?

I realized this too but I see Mahe already had flagged it to uplift so I preferred to wait
Well, this simply needs an approval request from André...
Flags: needinfo?(anatal)
Flags: needinfo?(mpotharaju)
Andre - I don't see the request flag.. Can you please set it and answer the questions that follow. 

Thanks
Comment on attachment 8685147 [details] [diff] [review]
This patch contains the gecko part of the fix.

NOTE: Please see https://wiki.mozilla.org/Release_Management/B2G_Landing to better understand the B2G approval process and landings.

[Approval Request Comment]
Bug caused by (feature/regressing bug #): 1194525 
User impact if declined: Apps (like Twitter) that doesn't correctly implement returnValue can fail 
Testing completed:  https://treeherder.mozilla.org/#/jobs?repo=try&revision=6013afafc7c9 
Risk to taking this patch (and alternatives if risky): -  
String or UUID changes made by this patch: -
Attachment #8685147 - Flags: approval‑mozilla‑b2g44?
Flags: needinfo?(anatal)
(In reply to Mahendra Potharaju [:mahe] from comment #83)
> Andre - I don't see the request flag.. Can you please set it and answer the
> questions that follow. 
> 
> Thanks

Hi Mahe. Just set it. 
Thanks
Let's hold off on uplift for right now -- Andre is investigating if bug 1221379 is a regression introduced by this fix.
Flags: needinfo?(mpotharaju)
Comment on attachment 8685147 [details] [diff] [review]
This patch contains the gecko part of the fix.

Sure. Thanks Dylan. Removed from request queue. 

Andre - Please set the flag once regression cause is identified and its safe for this patch to land. 

Thanks
Flags: needinfo?(mpotharaju)
Attachment #8685147 - Flags: approval‑mozilla‑b2g44? → approval‑mozilla‑b2g44-
Dylan, Mahendra, as far as I understand, bug 1221379 does not impact the user code, and not even the tests that test the user code...
(In reply to Julien Wajsberg [:julienw] from comment #88)
> Dylan, Mahendra, as far as I understand, bug 1221379 does not impact the
> user code, and not even the tests that test the user code...

Sorry! I pasted the wrong bug in there. The regression is bug 1224130.
See Also: → 1224130
Ah yeah, this one looks likely :D
Bug 1224130 was fixed 20 days ago by Bug 1224395. 

So I think we are good to land this one (Bug 1194525).
Flags: needinfo?(doliver)
André, don't forget we'll need to uplift bug 1224395 too, then.
Flags: needinfo?(doliver)
Attachment #8685147 - Flags: approval‑mozilla‑b2g44- → approval‑mozilla‑b2g44?
[Approval Request Comment]
Bug caused by (feature/regressing bug #): 1194525 
User impact if declined: Apps (like Twitter) that doesn't correctly implement returnValue can fail 
Testing completed:  https://treeherder.mozilla.org/#/jobs?repo=try&revision=6013afafc7c9 
Risk to taking this patch (and alternatives if risky): -  
String or UUID changes made by this patch: -
(In reply to Julien Wajsberg [:julienw] from comment #92)
> André, don't forget we'll need to uplift bug 1224395 too, then.

Thanks Julien. I just flagged both to uplift.
Andre - Can you please confirm there are no string changes in this patch?

Thanks
Flags: needinfo?(anatal)
Mahe, confirmed.
Flags: needinfo?(anatal)
Comment on attachment 8685147 [details] [diff] [review]
This patch contains the gecko part of the fix.

Approved for 2.5 uplift. Thanks
Attachment #8685147 - Flags: approval‑mozilla‑b2g44? → approval‑mozilla‑b2g44+
Just found this bug based on the error message "Error: postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp" I got.

I am actually still not entirely sure what I should do in my application - call "window.close" instead? But that then seems to trigger "NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIMessageSender.sendAsyncMessage]"

The other question is how is anyone ever going to find out what to do? The documentation at https://developer.mozilla.org/en-US/docs/Web/API/MozActivityRequestHandler definitely isn't sufficient. And to me it seems very strange to use window.close instead of a MozActivityRequestHandler method. My guess was to post a "null" result back, but that doesn't work any more now.
There are 2 solutions for you:
* either you add "returnValue: true" in your manifest, so that you can use postResult
* or you use window.close() because you don't have anything to return.

I think you can safely ignore the "NS_ERROR_ILLEGAl_VALUE" error, but still please file a separate bug for this one.

About developer.mozilla.org: well, it's a wiki, feel free to edit :) Actually we'd be glad ! (maybe more in https://developer.mozilla.org/en-US/docs/Web/API/Web_Activities#Handle_an_activity though ?)
I've added the following note to the articles in question:

Be aware that you need to have returnValue: true set in your manifest file to return a result (see manifest activities for more information.) If there is no result to return, then you should just use {{domxref("window.close()")}} to get rid of the handling window.

See:

https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/API/Web_Activities#Handle_an_activity
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/API/MozActivityRequestHandler
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: