fenix icon indicating copy to clipboard operation
fenix copied to clipboard

[Bug] "open link PB mode Fenix" and hit back, IllegalStateExceptionandroidx.fragment.app.FragmentManager in ensureExecReady, FragmentManager has been destroyed

Open TitanNano opened this issue 6 years ago • 31 comments

6/3 UPDATE There's a recent significant spike of this crash in Nightly starting May, 19: https://sentry.prod.mozaws.net/operations/fenix-nightly/issues/6457309/

Various cases of this fixed before: https://github.com/mozilla-mobile/fenix/issues?q=is%3Aissue+FragmentManager+has+been+destroyed+is%3Aclosed


Steps to reproduce

  1. start Fenix
  2. switch into PB mode
  3. go to devices launcher
  4. open a PWA

Expected behavior

The PWA will be launched

Actual behavior

The PWA activity appears briefly, but then fenix crashes.

Logcat

02-13 10:18:37.498 22826 22899 W FirefoxAccountStateMachine: Got invalid event Event$Init for state AuthenticatedWithProfile.
02-13 10:18:37.524  1929  3234 I InputDispatcher: Focus entered window: Window{e806487 u0 org.mozilla.fenix.nightly/org.mozilla.fenix.customtabs.ExternalAppBrowserActivity}
02-13 10:18:37.530  1929  3234 I ActivityManager: Displayed org.mozilla.fenix.nightly/org.mozilla.fenix.customtabs.ExternalAppBrowserActivity: +333ms (total +608ms)
02-13 10:18:37.531  1929  3234 I ActivityManager: Fully drawn org.mozilla.fenix.nightly/org.mozilla.fenix.customtabs.ExternalAppBrowserActivity: +333ms (total +608ms)
02-13 10:18:37.551 22826 22826 D GeckoSession: handleMessage GeckoView:PageStart uri=about:blank
02-13 10:18:37.555 22826 22826 D GeckoSession: handleMessage GeckoView:LocationChange uri=about:blank
02-13 10:18:37.555 22826 22826 D GeckoSession: handleMessage GeckoView:PageStop uri=null
02-13 10:18:37.556 22826 22826 D GeckoSession: handleMessage GeckoView:OnLoadRequest uri=https://web.telegram.org/?utm_source=web_app_manifest
02-13 10:18:37.559 22826 22826 D GeckoSession: handleMessage GeckoView:OnLoadRequest uri=https://web.telegram.org/?utm_source=web_app_manifest
02-13 10:18:37.571 22826 22826 W GeckoEventDispatcher: No listener for GeckoView:AccessibilityEnabled
02-13 10:18:37.573 22826 25271 D SessionStorage/AutoSave: Saved state to disk [446ms]
02-13 10:18:37.577 22826 22885 D GeckoScreenOrientation: unlocking
02-13 10:18:37.696 22826 22899 W FirefoxAccountStateMachine: Got invalid event Event$Init for state AuthenticatedWithProfile.
02-13 10:18:37.711 22826 22826 W DecorView[]: The visibility of the navigation bar is low, color=ffffffff, hasLightNavBar=false
02-13 10:18:37.732  1929  3800 I InputDispatcher: Focus entered window: Window{7a586aa u0 org.mozilla.fenix.nightly/org.mozilla.fenix.customtabs.ExternalAppBrowserActivity}
02-13 10:18:37.752 22826 22826 D AndroidRuntime: Shutting down VM
02-13 10:18:37.753 22826 22826 E AndroidRuntime: FATAL EXCEPTION: main
02-13 10:18:37.753 22826 22826 E AndroidRuntime: Process: org.mozilla.fenix.nightly, PID: 22826
02-13 10:18:37.753 22826 22826 E AndroidRuntime: java.lang.IllegalStateException: FragmentManager has been destroyed
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at androidx.fragment.app.FragmentManager.ensureExecReady(FragmentManager.java:4)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:1)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:873)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:280)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6744)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
02-13 10:18:37.753 22826 22826 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
02-13 10:18:37.754 22826 22885 D GeckoScreenOrientation: unlocking

Device information

  • Android device: SONY Xperia 10 Android 9
  • Fenix version: Nightly 2002112 18:00 (Build #20431806) 32.0.0, 747da16b0

┆Issue is synchronized with this Jira Task

TitanNano avatar Feb 13 '20 09:02 TitanNano

I tried to reproduce this but for me the PWA opens and functions correctly. Can someone from QA try to reproduce this?

ValentinTimisica avatar Feb 21 '20 10:02 ValentinTimisica

I tried to reproduce this issue but without any success. No crash is displayed using the PWA with Private Browsing.

Devices:

  • Samsung Galaxy S8 (Android 9);
  • OnePlus 6T (Android 9);
  • Google Pixel 3a (Android 9).

Build: Firefox Preview Nightly 2/21 #20520606.

sv-sdeiac avatar Feb 21 '20 14:02 sv-sdeiac

I also can no longer reproduce this.

TitanNano avatar Feb 25 '20 22:02 TitanNano

Closing as fixed

ekager avatar Feb 26 '20 06:02 ekager

Hi, Still reproducible on the latest Nightly Build #20570604 from 02/26 using the following devices: • Huawei Mate 20 Lite (Android 8.1.0) • Samsung Galaxy S7 (Android 7) • OnePlus A3 (Android 6.0.1) • LG Nexus 4 (Android 5.1.1)

❗ Not reproducible on Google Pixel 3a (Android 9)

► Video 20200226-113451 (1)

► Crashlog

  --------- beginning of crash
2020-02-26 11:35:06.682 29357-29357/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.mozilla.fenix.nightly, PID: 29357
    java.lang.RuntimeException: Unable to resume activity {org.mozilla.fenix.nightly/org.mozilla.fenix.nightly.App}: java.lang.RuntimeException: Failed to call observer method
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4278)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4319)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2065)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:166)
        at android.app.ActivityThread.main(ActivityThread.java:7555)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
     Caused by: java.lang.RuntimeException: Failed to call observer method
        at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:6)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:2)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:1)
        at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:1)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:3)
        at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:9)
        at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:12)
        at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:5)
        at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:2)
        at androidx.fragment.app.Fragment.performStart(Fragment.java:7)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:108)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:4)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:218)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3)
        at androidx.fragment.app.Fragment.performStart(Fragment.java:14)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:108)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:4)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:218)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:18)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:1)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1340)
        at android.app.Activity.performStart(Activity.java:7364)
        at android.app.Activity.performRestart(Activity.java:7439)
        at android.app.Activity.performResume(Activity.java:7444)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4246)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4319) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2065) 
        at android.os.Handler.dispatchMessage(Handler.java:109) 
        at android.os.Looper.loop(Looper.java:166) 
        at android.app.ActivityThread.main(ActivityThread.java:7555) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963) 
     Caused by: java.lang.IllegalStateException: SET SESSION: Current activity: HomeActivity Other activity: ExternalAppBrowserActivity
        at mozilla.components.browser.engine.gecko.GeckoEngineView.render(GeckoEngineView.kt:17)
        at mozilla.components.feature.session.EngineViewPresenter.renderSession$feature_session_release(EngineViewPresenter.kt:1)
        at mozilla.components.feature.session.SessionFeature.start(SessionFeature.kt:6)
        at mozilla.components.support.base.feature.ViewBoundFeatureWrapper.start$support_base_release(ViewBoundFeatureWrapper.kt:1)
        at mozilla.components.support.base.feature.LifecycleBinding.start(ViewBoundFeatureWrapper.kt:1)
        at java.lang.reflect.Method.invoke(Native Method)
        at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:4)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:2) 
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:1) 
        at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:1) 
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:3) 
        at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:9) 
        at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:12) 
        at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:5) 
        at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:2) 
        at androidx.fragment.app.Fragment.performStart(Fragment.java:7) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:108) 
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:4) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:218) 
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3) 
        at androidx.fragment.app.Fragment.performStart(Fragment.java:14) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:108) 
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:4) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:218) 
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3) 
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:18) 
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:1) 
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1340) 
        at android.app.Activity.performStart(Activity.java:7364) 
        at android.app.Activity.performRestart(Activity.java:7439) 
        at android.app.Activity.performResume(Activity.java:7444) 
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4246) 
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4319) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2065) 
        at android.os.Handler.dispatchMessage(Handler.java:109) 
        at android.os.Looper.loop(Looper.java:166) 
        at android.app.ActivityThread.main(ActivityThread.java:7555) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963) 
     Caused by: java.lang.IllegalStateException: Display already acquired
        at org.mozilla.geckoview.GeckoSession.acquireDisplay(GeckoSession.java:5)
2020-02-26 11:35:06.682 29357-29357/? E/AndroidRuntime:     at org.mozilla.geckoview.GeckoView.setSession(GeckoView.java:7)
        at mozilla.components.browser.engine.gecko.GeckoEngineView.render(GeckoEngineView.kt:10)
        	... 39 more
2020-02-26 11:35:06.683 29357-29357/? I/mozac/CrashReporter: Received crash: UncaughtExceptionCrash(throwable=java.lang.RuntimeException: Unable to resume activity {org.mozilla.fenix.nightly/org.mozilla.fenix.nightly.App}: java.lang.RuntimeException: Failed to call observer method, breadcrumbs=[Breadcrumb(message=Changing to fragment homeFragment, isCustomTab: false, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:34:40 GMT+02:00 2020), Breadcrumb(message=Changing to fragment settingsFragment, isCustomTab: false, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:34:43 GMT+02:00 2020), Breadcrumb(message=Changing to fragment privateBrowsingFragment, isCustomTab: false, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:34:44 GMT+02:00 2020), Breadcrumb(message=Changing to fragment settingsFragment, isCustomTab: false, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:34:54 GMT+02:00 2020), Breadcrumb(message=Changing to fragment homeFragment, isCustomTab: false, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:34:55 GMT+02:00 2020), Breadcrumb(message=Changing to fragment externalAppBrowserFragment, isCustomTab: true, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:34:58 GMT+02:00 2020), Breadcrumb(message=Changing to fragment externalAppBrowserFragment, isCustomTab: true, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:35:06 GMT+02:00 2020), Breadcrumb(message=Changing to fragment browserFragment, isCustomTab: false, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Wed Feb 26 11:35:06 GMT+02:00 2020)])
2020-02-26 11:35:06.683 29357-29357/? I/mozac/CrashReporter: Showing prompt

AndiAJ avatar Feb 26 '20 09:02 AndiAJ

Thanks @AndiAJ ! Slightly different trace now but that's good info to keep looking into

ekager avatar Feb 26 '20 15:02 ekager

With the original STR I'm still seeing on my Pixel 3 (but only sometimes)

2020-04-17 17:00:54.708 18721-18721/org.mozilla.fenix.debug E/AndroidRuntime: FATAL EXCEPTION: main Process: org.mozilla.fenix.debug, PID: 18721 java.lang.IllegalStateException: FragmentManager has been destroyed at androidx.fragment.app.FragmentManager.ensureExecReady(FragmentManager.java:1783) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1843) at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

ekager avatar Apr 18 '20 00:04 ekager

This seems to be related to one of the most common signatures we are seeing on Nightly. Crash in [@ java.lang.IllegalStateException: at androidx.fragment.app.FragmentManager.ensureExecReady(FragmentManager.java)] bug 1641040

kbrosnan avatar May 27 '20 01:05 kbrosnan

I'm going to dupe these to #10709, and I've moved STRs over bc these all have the same crash signature.

liuche avatar Jun 03 '20 15:06 liuche

My bad, this is not the same bug as #10709, will do some un-duping.

liuche avatar Jun 03 '20 17:06 liuche

This is currently our top crasher on Firefox Beta at 5% rollout: https://crash-stats.mozilla.org/topcrashers/?product=Fenix&version=77.0.0-b

and on Firefox Preview too, top crashes 1 & 2 with an uptick in the past few days: https://sentry.prod.mozaws.net/operations/firefox-nightly/?query=release%3Aorg.mozilla.fenix-5.1.0&sort=priority&statsPeriod=14d

(crash-stats link for reference) https://crash-stats.mozilla.org/topcrashers/?product=Fenix&version=5.1.0-b

also updating the title to make this more searchable by crash signature.

liuche avatar Jun 03 '20 17:06 liuche

@grigoryk @NotWoods what do you think of this one?

st3fan avatar Jun 03 '20 18:06 st3fan

fwiw this is probably some kind of race, bc this STR has been around for a while, but has really spiked on Nightly as of May 19.

liuche avatar Jun 03 '20 18:06 liuche

From: https://www.reddit.com/r/firefox/comments/gvaru6/firefox_preview_nightly_still_crashing_on_samsung/

I have been running the Joey Reddit app as a standalone app and I will occasionally open a post externally in Firefox Preview Nightly to bookmark it. Then I hit the back button twice to go back to the Joey app and as soon as it goes back, I get the message that Firefox has crashed. I tried to duplicate the problem just now and I wasn't able to. It only occasionally happens.

kbrosnan avatar Jun 03 '20 19:06 kbrosnan

@ekager backx2? #10718

liuche avatar Jun 03 '20 20:06 liuche

@grigoryk if you're looking into this, might be related to app restarts when swapping themes (because Private Browsing is a separate theme and requires application recreate to apply).

Chatted w/ @boek and @ekager about one solution being, removing the PB theming and instead, dynamically setting UI colors for PB Mode.

liuche avatar Jun 04 '20 17:06 liuche

Yeah the backx2 issue was #10718 🤔

ekager avatar Jun 04 '20 17:06 ekager

@ekager this landed on the 18th and fits the STR https://github.com/mozilla-mobile/fenix/commit/d46369696f1d43385f335936f50abb31176845ef

st3fan avatar Jun 04 '20 18:06 st3fan

Yes, I'm convinced that the spike is related to https://github.com/mozilla-mobile/fenix/commit/d46369696f1d43385f335936f50abb31176845ef but think it is just exposing another pathway to an issue that already existed when finishing activities (ie the previous STR also involved "open in Fenix" which finishes an activity). There's clearly another root issue at play here - probably some race condition as the activity finishes, but for now we can revert the finish.

ekager avatar Jun 04 '20 18:06 ekager

I just repro-ed the crash on the original STR.

  1. Have Fenix open in PBM homescreen
  2. Background Fenix, Open PWA
  3. Click away from main PWA scope to get toolbar
  4. Select "Open in Fenix" from toolbar

Took me about 10-15 tries and then reproed a second time as well.

ekager avatar Jun 04 '20 18:06 ekager