Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Prevent GeckoSession creation until tab is viewed #2238

Merged
merged 4 commits into from
Nov 14, 2019
Merged

Conversation

bluemarvin
Copy link
Contributor

Fixes #2227
To prevent memory exhaustion, this patch watches for memory trim system
callbacks and suspends inactive tabs by deleting the GeckoSession.
Additionally, when the application is started or resumed, inactive tabs will
not have a GeckoSession created until they are viewed. Any new background tab
will also not have a GeckoSession created until the tab is viewed.

@bluemarvin bluemarvin added this to the #6 features milestone Nov 12, 2019
@bluemarvin bluemarvin self-assigned this Nov 12, 2019
Copy link
Contributor

@MortimerGoro MortimerGoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After opening a few tabs and playing with switching I got a broken session. Video attached:

broken_session.mp4.zip
logcat.txt

@bluemarvin
Copy link
Contributor Author

After opening a few tabs and playing with switching I got a broken session. Video attached:

broken_session.mp4.zip
logcat.txt

@MortimerGoro I think I've fixed the issue.

@keianhzo
Copy link
Contributor

@bluemarvin I manage to get a reproducible crash:

STRs:

  • Open FxR
  • Switch to private mode and open 2 tabs
  • Switch back to regular mode
  • Start opening and switching between tabs until you start get suspended sessions in the log
  • Switch back to private mode
  • Open the tabs panel and switch to the inactive tab

The app crashes with the following stacktrace.

2019-11-13 16:58:51.089 14402-14402/org.mozilla.vrbrowser.dev E/GeckoCrashHandler: >>> REPORTING UNCAUGHT EXCEPTION FROM THREAD 1 ("main")
    java.lang.IllegalArgumentException: Display not attached
        at org.mozilla.geckoview.GeckoSession.releaseDisplay(GeckoSession.java:2409)
        at org.mozilla.vrbrowser.ui.widgets.WindowWidget.releaseDisplay(WindowWidget.java:1045)
        at org.mozilla.vrbrowser.ui.widgets.WindowWidget.onCurrentSessionChange(WindowWidget.java:1069)
        at org.mozilla.vrbrowser.ui.widgets.WindowWidget.setSession(WindowWidget.java:1029)
        at org.mozilla.vrbrowser.ui.widgets.Windows.addTab(Windows.java:1164)
        at org.mozilla.vrbrowser.ui.widgets.Windows.onTabAdd(Windows.java:1182)
        at org.mozilla.vrbrowser.ui.widgets.TabsWidget$TabAdapter$1.onAdd(TabsWidget.java:273)
        at org.mozilla.vrbrowser.ui.views.TabView$1.onClick(TabView.java:128)
        at android.view.View.performClick(View.java:5637)
        at android.view.View$PerformClick.run(View.java:22436)
        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:6144)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Copy link
Contributor

@MortimerGoro MortimerGoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluemarvin bluemarvin force-pushed the feature/memory branch 2 times, most recently from 6314107 to ad54870 Compare November 13, 2019 21:44
@bluemarvin
Copy link
Contributor Author

I think both issues have been addressed but I'm sure there are more.

@keianhzo
Copy link
Contributor

keianhzo commented Nov 14, 2019

Couldn't trigger the crash anymore but I got this a transparent window after switching to a private session, same STRs as before:

ezgif com-video-to-gif(1)

I couldn't see anything weird in the logs:
logcat.txt

@bluemarvin
Copy link
Contributor Author

The transparent window has to do with how we manage first paint. It's annoying but I don't think it is a blocker.

@bluemarvin
Copy link
Contributor Author

Actually that transparent window is a problem. I thought it was only while the page was loading. I'll look into it quickly. But the fact that it is transparent means the compositor cleared it but then didn't render anything else.

Fixes #2227
To prevent memory exhaustion, this patch watches for memory trim system
callbacks and suspends inactive tabs by deleting the GeckoSession.
Additionally, when the application is started or resumed, inactive tabs will
not have a GeckoSession created until they are viewed. Any new background tab
will also not have a GeckoSession created until the tab is viewed.
@MortimerGoro MortimerGoro merged commit 0b2917e into master Nov 14, 2019
@MortimerGoro MortimerGoro deleted the feature/memory branch November 14, 2019 20:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants