Open Bug 1657698 Opened 5 years ago Updated 3 years ago

Suspended pages are not put into bfcache

Categories

(GeckoView :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: snorp, Unassigned)

Details

(Whiteboard: [geckoview:2023?])

Attachments

(1 obsolete file)

Some context here: https://github.com/mozilla-mobile/fenix/issues/12928

GeckoView suspends inactivate (background) pages in order to help reduce battery consumption. We do this automatically based on whether or not the page is on the screen. In the case of Fenix, there is fullscreen UI on top of the content when you enter a new URL, which causes us to set the current tab inactive and therefore suspend it. @mstange found that when the new navigation occurs, the current page is not put into the bfcache because it is already suspended[1].

Can we remove this restriction? It's not entirely clear to me what it's trying to avoid. Maybe GeckoView should be freezing windows instead of suspending?

[1] https://searchfox.org/mozilla-central/rev/26b13464c2beb26e0d864d561c30e817a85c348a/dom/base/Document.cpp#10425-10436

Wasn't there some change around this some time ago. I thought it was fixed on Fenix side, has that regressed?
Trying to find the relevant bug (or do I misremember).

(In reply to Olli Pettay [:smaug] from comment #1)

Wasn't there some change around this some time ago. I thought it was fixed on Fenix side, has that regressed?
Trying to find the relevant bug (or do I misremember).

You may be thinking of Bug 1639577, where we fixed things for pages that communicate with background pages via window.opener.

Freezing instead of suspending seems like it would make bfcache work. It would also stop workers which we probably want to do anyway. Olli, do you have any concern with moving to that instead of suspending as we do now?

Flags: needinfo?(bugs)

Freeze has been used with bfcache and with the old document when loading a new one. Suspend also when dealing with modal dialogs.
We certainly don't want to move pages which have modal dialogs open to the bfcache.
Freeze might work.

Docshell's isActive is different thing. It deals with background vs foreground tabs and affects to setTimeout and rAF behavior.

Which one is Fenix using?

Would it be possible for Fenix to resume/thaw right before the new navigation? That at least sounds the easiest way to fix this.

(bug 1639577 is not the one I'm thinking. The bug had something to do with double suspend or double freezing.)

Flags: needinfo?(bugs)

(In reply to Olli Pettay [:smaug] from comment #3)

Freeze has been used with bfcache and with the old document when loading a new one. Suspend also when dealing with modal dialogs.
We certainly don't want to move pages which have modal dialogs open to the bfcache.

Indeed, that makes sense.

Freeze might work.

Docshell's isActive is different thing. It deals with background vs foreground tabs and affects to setTimeout and rAF behavior.

Yeah, that only throttles callbacks. We'd like to stop them entirely. I think it can still fire stuff once a second, which can really add up if you have several pages open.

Which one is Fenix using?

We set the docshell inactive but also call Suspend() right now.

Would it be possible for Fenix to resume/thaw right before the new navigation? That at least sounds the easiest way to fix this.

Yeah, that does seem reasonable. I'll give it a shot.

Assignee: nobody → snorp
Severity: -- → S3
Priority: -- → P1
Component: DOM: Navigation → General
Product: Core → GeckoView
Priority: P1 → P2
Attachment #9169267 - Attachment is obsolete: true

The bug assignee didn't login in Bugzilla in the last 7 months.
:amoya, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: snorp → nobody
Flags: needinfo?(amoya)

Recap: This bug can be reproduced when the app calls loadUri while the tab is not active. Fenix's tab tray used to completely hide the current tab which caused it to be hidden and therefore not active.

Currently this shouldn't happen, but we should double check that, especially for new tabs.

Priority: P2 → P3
Whiteboard: [geckoview:2023?]
Flags: needinfo?(amoya)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: