Closed Bug 1440592 Opened 7 years ago Closed 7 years ago

Crash in java.lang.IllegalStateException: Unexpected new session at org.mozilla.gecko.customtabs.CustomTabsActivity.onNewSession(CustomTabsActivity.java)

Categories

(GeckoView :: General, defect, P1)

Unspecified
Android
defect

Tracking

(firefox-esr52 unaffected, firefox58 unaffected, firefox59 unaffected, firefox60blocking fixed, firefox61 fixed)

RESOLVED FIXED
mozilla61
Tracking Status
firefox-esr52 --- unaffected
firefox58 --- unaffected
firefox59 --- unaffected
firefox60 blocking fixed
firefox61 --- fixed

People

(Reporter: calixte, Assigned: esawin)

References

(Blocks 1 open bug)

Details

(Keywords: crash, regression, topcrash)

Crash Data

Attachments

(4 files, 4 obsolete files)

This bug was filed from the Socorro interface and is report bp-b4d8b827-a05f-418d-830f-2e5d70180223. ============================================================= java.lang.IllegalStateException: Unexpected new session at org.mozilla.gecko.customtabs.CustomTabsActivity.onNewSession(CustomTabsActivity.java:656) at org.mozilla.geckoview.GeckoSession$2.handleMessage(GeckoSession.java:150) at org.mozilla.geckoview.GeckoSession$2.handleMessage(GeckoSession.java:127) at org.mozilla.geckoview.GeckoSessionHandler.handleMessage(GeckoSessionHandler.java:91) at org.mozilla.gecko.EventDispatcher$2.run(EventDispatcher.java:341) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6316) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) ============================================================= There are 16 crashes (from 12 installations) in nightly 60 with buildid 20180223001836. In analyzing the backtrace, the regression may have been introduced by patch [1] to fix bug 1432485. [1] https://hg.mozilla.org/mozilla-central/rev?node=d39e77de7c54
Flags: needinfo?(snorp)
Crash Signature: [@ java.lang.IllegalStateException: Unexpected new session at org.mozilla.gecko.customtabs.CustomTabsActivity.onNewSession(CustomTabsActivity.java)] → [@ java.lang.IllegalStateException: Unexpected new session at org.mozilla.gecko.customtabs.CustomTabsActivity.onNewSession(CustomTabsActivity.java)] [@ java.lang.IllegalStateException: Unexpected new session at org.mozilla.gecko.webapps.WebAppActivity.on…
The signature "java.lang.IllegalStateException: Unexpected new session at org.mozilla.gecko.customtabs.CustomTabsActivity.onNewSession(CustomTabsActivity.java)" is ranked #1 in nightly top-crashers for FennecAndroid.
Keywords: topcrash
530 crashes/369 since this was initially filed.
I can reproduce this. I opened a link to a facebook video from the reddit app. Then when I tap play it crashes.
In bug 1396065 we've used the wrong constant for new window and with the introduction of onNewSession we run into unexpected behavior because of it.
Assignee: nobody → esawin
Flags: needinfo?(snorp)
Attachment #8954365 - Flags: review?(bugs)
Comment on attachment 8954365 [details] [diff] [review] 0001-Bug-1440592-1.0-Use-correct-where-constant-for-new-w.patch uh, those flags are confusing.
Attachment #8954365 - Flags: review?(bugs) → review+
I was able to reproduce this crash 5/5 times on HTC 10(Android 8.1.0), Samsung Galaxy S8(Android 7.0) and Nexus 5 (Android 6.0.1) following the steps: 1. Open a page using Custom Tab; 2. Long tap on a word and from selection menu choose Google search. Actual results: Nightly crashes and the search query is not opened.
Pushed by esawin@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/dcadcf486b78 [1.0] Use correct where constant for new window. r=smaug
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
There still are 299 crashes in nightly 60 with buildid >= 20180301223345 (see [1]) with signature "java.lang.IllegalStateException: Unexpected new session at org.mozilla.gecko.customtabs.CustomTabsActivity.onNewSession(CustomTabsActivity.java)". [1] http://bit.ly/2oLimb4
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: Firefox 60 → ---
Flags: needinfo?(esawin)
We need to handle openURI calls according to our general scheme (1. delegate to app, 2. create new session if required, 3. load the URI).
Flags: needinfo?(esawin)
Attachment #8957561 - Flags: review?(snorp)
Removed unnecessary module import.
Attachment #8957561 - Attachment is obsolete: true
Attachment #8957561 - Flags: review?(snorp)
Attachment #8957563 - Flags: review?(snorp)
Comment on attachment 8957561 [details] [diff] [review] 0001-Bug-1440592-2.0-Enable-URI-loading-delegation-in-ope.patch Review of attachment 8957561 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/modules/geckoview/LoadURIDelegate.jsm @@ +11,5 @@ > +XPCOMUtils.defineLazyModuleGetters(this, { > + Services: "resource://gre/modules/Services.jsm", > +}); > + > +XPCOMUtils.defineLazyServiceGetter(this, "ParentalControls", We don't use this @@ +19,5 @@ > + // Delegate URI loading to the app. > + // Return whether the loading has been handled. > + load: function(aEventDispatcher, aUri, aWhere, aFlags, aTriggeringPrincipal) { > + const message = { > + type: "GeckoView:OnLoadUri", The public thing is onLoadRequest() now, maybe we should rename these messages too while we're at it.
Attachment #8957561 - Flags: review+
Comment on attachment 8957563 [details] [diff] [review] 0002-Bug-1440592-2.0-Enable-URI-loading-delegation-in-ope.patch Review of attachment 8957563 [details] [diff] [review]: ----------------------------------------------------------------- I guess I reviewed the wrong one earlier?
Attachment #8957563 - Flags: review?(snorp) → review+
Pushed by esawin@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/80169b025661 [2.0] Enable URI-loading delegation in openURI. r=snorp https://hg.mozilla.org/integration/mozilla-inbound/rev/7f0371f3d5f7 [3.0] Rename GeckoView event onLoadURI to onLoadRequest. r=snorp
Pushed by esawin@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/2c9d1c92da9b [4.0] Fix linter errors on CLOSED TREE. r=me
This is still around in 60.0b3 (and 61.0a1): https://crash-stats.mozilla.com/signature/?product=FennecAndroid&version=60.0b&signature=java.lang.IllegalStateException%3A Unexpected new session at org.mozilla.gecko.customtabs.CustomTabsActivity.onNewSession(CustomTabsActivity.java)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
The remaining crashes might be related to the startup race, let's see if bug 1446423 helps.
Depends on: 1446423
By far the top crasher in 60.0b4
Eugen, are you still looking at this?
Flags: needinfo?(esawin)
There are paths for window creations (nsWindowWatcher::OpenWindowInternal) which do not call into the docshell before creating a new window. Currently, this would result in createContentWindow and therefore onNewSession calls without prior option to deflect the creation via onLoadRequest. We need to either allow onNewSession to return the current session, which would require adjustments in Gecko, or we guarantee that onLoadRequest is always called prior to onNewSession to allow the app to handle that appropriately. This patch implements the latter solution by partly restoring the old (pre-onNewSession) handling for content window creation. We need to delegate the load to the app before requesting the new session. On success, we need to abort the handling in Gecko by throwing NS_ERROR_ABORT to prevent further attempts of window creation and attaching. This will bring back the old JavaScript exception log.
Flags: needinfo?(esawin)
Attachment #8962717 - Flags: review?(snorp)
New STR would include a page with a target=_blank link inside an iframe.
Comment on attachment 8962717 [details] [diff] [review] 0004-Bug-1440592-4.0-Allow-load-delegation-when-opening-w.patch Review of attachment 8962717 [details] [diff] [review]: ----------------------------------------------------------------- I think I would rather just accept that onLoadRequest() isn't called sometimes when onNewSession() is called, and just stop throwing here in CustomTabsActivity, etc. Let's get a bug on file for the underlying issue, though. onNewSession() and onLoadRequest() are pretty much equivalent for the "new window" case, so maybe it's ok to specify that onLoadRequest() is only called for navigations within the session?
Attachment #8962717 - Flags: review?(snorp) → review-
I think we have a few options here: 1) Change the behavior of onLoadRequest() such that it is only fired for loads in the same session. We would remove the 'target' argument entirely, since it's always assumed to be the current session. onNewSession() would be how you prevent or otherwise handle loads that need a new session. I think this would simply need a patch in the docshell to check some flags before calling onLoadRequest(). 2) Plug the current hole by calling onLoadRequest() in the cases we aren't handling it now. It should be possible to get the originating docshell and call onLoadRequest() in nsWindowWatcher::OpenWindowInternal(), for instance. 3) Overhaul the whole API around these two delegates. In bug 1437701 I'll be adding yet another "handle loading this URI" type of delegate method, and they all seem very similar. It seems like we should be able to do better.
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #26) > I think we have a few options here: > > 1) Change the behavior of onLoadRequest() such that it is only fired for > loads in the same session. We would remove the 'target' argument entirely, > since it's always assumed to be the current session. onNewSession() would be > how you prevent or otherwise handle loads that need a new session. I think > this would simply need a patch in the docshell to check some flags before > calling onLoadRequest(). With the current constraints of onNewSession, it would make it difficult for the app to appropriately handle some cases and signal correct behavior back to Gecko. I think a single delegate callback for all page load-related overrides is preferable and easier to communicate. > 2) Plug the current hole by calling onLoadRequest() in the cases we aren't > handling it now. It should be possible to get the originating docshell and > call onLoadRequest() in nsWindowWatcher::OpenWindowInternal(), for instance. Handling this in GVNavigation will ensure we enclose all code paths and signal NS_ERROR_ABORT to stop Gecko from handling it. This would also be more robust against changes on Gecko's side. > 3) Overhaul the whole API around these two delegates. In bug 1437701 I'll be > adding yet another "handle loading this URI" type of delegate method, and > they all seem very similar. It seems like we should be able to do better. I agree that the API could be better, we can follow up on that.
Attachment #8962717 - Attachment is obsolete: true
Attachment #8962785 - Flags: review?(snorp)
Comment on attachment 8962785 [details] [diff] [review] 0004-Bug-1440592-4.1-Allow-load-delegation-when-opening-w.patch Review of attachment 8962785 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/modules/geckoview/GeckoViewNavigation.jsm @@ +184,5 @@ > if (browser) { > browser.setAttribute("nextTabParentId", aNextTabParentId); > } > > return browser; I wonder, do we want to set NS_ERROR_ABORT here if browser is null? @@ +200,3 @@ > } > > + let browser = this.browser; const, event though it was wrong before
Attachment #8962785 - Flags: review?(snorp) → review+
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #28) > Comment on attachment 8962785 [details] [diff] [review] > 0004-Bug-1440592-4.1-Allow-load-delegation-when-opening-w.patch > > Review of attachment 8962785 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: mobile/android/modules/geckoview/GeckoViewNavigation.jsm > @@ +184,5 @@ > > if (browser) { > > browser.setAttribute("nextTabParentId", aNextTabParentId); > > } > > > > return browser; > > I wonder, do we want to set NS_ERROR_ABORT here if browser is null? Good point, I think we should set it and the same holds for createContentWindow. Returning a null window with NS_OK triggers Gecko's window creator path, which will fail for GV. > @@ +200,3 @@ > > } > > > > + let browser = this.browser; > > const, event though it was wrong before browser gets reassigned.
Attachment #8962785 - Attachment is obsolete: true
Attachment #8962820 - Flags: review?(snorp)
Comment on attachment 8962820 [details] [diff] [review] 0004-Bug-1440592-4.2-Allow-load-delegation-when-opening-w.patch Review of attachment 8962820 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/modules/geckoview/GeckoViewNavigation.jsm @@ +164,5 @@ > + if (browser) { > + return browser.contentWindow; > + } > + > + Components.returnCode = Cr.NS_ERROR_ABORT; So we'll end up returning 'undefined' here which seems a bit weird. Nobody should be using the return value, though, if the call failed. Maybe invert the condition above if you feel like it. @@ +180,5 @@ > > + if (LoadURIDelegate.load(this.eventDispatcher, aUri, aWhere, aFlags, null)) { > + // The app has handled the load, abort open-window handling. > + Components.returnCode = Cr.NS_ERROR_ABORT; > + return; Same as above, maybe we should return null. Just seems wrong to sometimes return a value and other times not.
Attachment #8962820 - Flags: review?(snorp) → review+
Addressed comments.
Attachment #8962820 - Attachment is obsolete: true
Attachment #8962867 - Flags: review+
Pushed by esawin@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/15eed3a9a8e3 [4.3] Allow load delegation when opening windows before requesting a new session. r=snorp
Status: REOPENED → RESOLVED
Closed: 7 years ago7 years ago
Resolution: --- → FIXED
Please request Beta approval on this when you get a chance so we can get it in for Monday's b9 build.
Flags: needinfo?(esawin)
Target Milestone: Firefox 60 → Firefox 61
Comment on attachment 8962867 [details] [diff] [review] 0004-Bug-1440592-4.3-Allow-load-delegation-when-opening-w.patch Looks like this is the only patch that didn't make it to 60 and bug 1446423 didn't seem to move crash stats at all. Approval Request Comment [Feature/Bug causing the regression]: Bug 1432485. [User impact if declined]: Crash on page load. [Is this code covered by automated tests?]: No. [Has the fix been verified in Nightly?]: Verified locally, crash stats went down to 0 crashes. [Needs manual test from QE? If yes, steps to reproduce]: Maybe? STR: Open page with embedded YouTube video, click on the title of the video inside the video frame. [List of other uplifts needed for the feature/fix]: None. [Is the change risky?]: Somewhat. [Why is the change risky/not risky?]: It changes behavior for some cases of page loading, but it only affects custom tabs and web apps. [String changes made/needed]: None.
Flags: needinfo?(esawin)
Attachment #8962867 - Flags: approval-mozilla-beta?
Comment on attachment 8962867 [details] [diff] [review] 0004-Bug-1440592-4.3-Allow-load-delegation-when-opening-w.patch Fennec topcrash fix. Approved for 60.0b9.
Attachment #8962867 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Product: Firefox for Android → GeckoView
Target Milestone: Firefox 61 → mozilla61
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: