New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 821064 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 1
Type: Bug



Sign in to add a comment

OOPIF with form inputs scrolls to wrong spot when restoring in hidden tab

Project Member Reported by creis@chromium.org, Mar 12 2018

Issue description

Chrome Version: 67.0.3368.0
OS: Mac

What steps will reproduce the problem?
(1) Start Chrome with --site-per-process.
(2) Visit http://csreis.github.io/tests/cross-site-iframe-simple.html
(3) Open another tab in the same window.
(4) Visit chrome://restart from the new tab.
(5) Wait until both tabs have finished loading, then switch back to first tab.

What is the expected result?
The iframe should be at the top, saying "Before you may cross..."

What happens instead?
Instead, the iframe has scrolled halfway down its document, showing the date and color picker questions.

This also repros if you close the whole window and and reopen it (ctrl+shift+T) without quitting Chrome.

It only repros with Site Isolation enabled, when the iframe is an OOPIF.  It does not repro if you restart with the first tab visible, or if you switch tabs in step 5 before the first tab has loaded in the background.  (You can usually see when this load happens, since it's delayed and briefly shows the spinner.)

The form field may also be involved, since the bug doesn't seem to repro if you use http://csreis.github.io/tests/cross-site-iframe.html and click on the complex frame button.

I suspect this is a combination of OOPIFs, form field focus, visibility, and maybe scroll restoration (anchoring?).  ekaramad@, can you take a look to see if it's related to scrolling a field into view?
 

Comment 1 by creis@chromium.org, Mar 12 2018

Labels: -Pri-2 Target-66 M-66 FoundIn-65 OS-Chrome OS-Linux OS-Windows Pri-1
Also repros on 65.0.3325.146 on Linux, so presumably this is cross-platform.  Raising priority-- if it's a simple fix, maybe we can merge to M66.
FWIW, Scroll anchor restoration isn't turned on for M65. Root layer scrolling is an unlikely culprit for the same reason.
I can repro this on Linux 67.0.3365.0 but was unable to repro on Windows Canary. 

Focusing <input> should lead to scrollIntoView():
LayoutObject::ScrollRectToVisible
HTMLInputElement::UpdateFocusAppearanceWithOptions
Document::SetFocusedElement
...

so one hypothesis could be that we are not setting the focused element properly in some cases. But the weirdness this theory fails to explain is that a) why do we even end up at a different scroll position, and b) why is it behaving differently on windows.

I could try and run a bisec and see if there are any clearer clues on what might have caused this.

FYI I can reproduce this bug by just right-clicking the link in step 2) and opening in a new tab.

Comment 5 by creis@chromium.org, Mar 12 2018

I can repro this on Windows Canary 67.0.3368.0.  Maybe try again? 

Agreed about the "Open in link new tab" repro steps-- happens to middle click as well.
This seems broken since as early as 55.0.2881.0 (Developer Build) (64-bit).
I did some digging into this and found that the root cause is

a) "autofocus" on first <input/>
b) Strange (incorrect?) AbsoluteBoundingBox() for the <input/> when autofocus occurs.

The AbsoluteBoundingBox() of <input/> is different when we load the page first and after the reload from chrome://restart (or alternatively as open in new tab by right clicking the link).

So this to me seems like a Layout bug.

Comment 8 by creis@chromium.org, Mar 12 2018

Cc: wjmaclean@chromium.org kenrb@chromium.org
Components: Blink>Layout
Nice progress-- adding Layout component per comment 7.

Do you plan to keep looking, or should we find an owner in the layout team?
I am not quite familiar with layout so I think finding an owner in layout team should be more efficient.

I also forgot to mention a third factor with this bug which is the use of external CSS stylesheets on the page. Removing the links seems to resolve the issue (tested on a local server).

So all in all, my understanding is that there is some races due to loading CSS and layout (which might be quite normal and expected) which together with autofocus leads to the wrong behavior.  

Comment 10 by nasko@chromium.org, Mar 19 2018

Cc: ekaramad@chromium.org
Owner: chrishtr@chromium.org
chrishtr@, can someone from the layout team take a look at this one?
Will do.
I found the following:

1. The scrolling is indeed due to autofocus.
3. During "load" of the OOPIF sub-frame, the autofocus attribute is noticed
and a task is put on the event queue for it.
4. The task calls Element.focus()
5. At this time, layout is actually dirty because the lifecycle has not started
for the sub-frame.
6. Element::focus() calls UpdateStyleAndLayoutTreeIgnorePendingStylesheetsForNode
to address situations such as #5.
7. There is another layout that happens on the sub-frame after #6.
8. The lifecycle for the OOPIF sub-frame is *never run* until the tab containing it is
shown. This is not true of its parent frame, which does get a lifecycle run.

It seems clear that putting a task on the event queue during page load is not a reliable
heuristic. However, I suspect that #8 is actually the proximate cause of this bug.
Is it expected that OOPIF sub-frames in background tabs don't get lifecycle updates?
I did verify that the OOPIF sub-frame is *not* throttled in the LocalFrameView::ShouldThrottleRendering sense.

Comment 13 Deleted

Owner: ekaramad@chromium.org
-> ekaramad for next steps to find out why OOPIF sub-frames inside of 
background tabs don't get these lifecyle updates even though it appears the
parent does. I consulted with kenrb and it seems this is not expected.

Comment 15 by creis@chromium.org, Mar 30 2018

Labels: -Target-66 Target-67
Owner: panicker@chromium.org
panicker@: Can you help with comment 14?  Sounds like OOPIFs might not be getting lifecycle updates in background tabs.  (Ehsan, feel free to take this back, but I'm guessing you're out until Tuesday.)

Given the timing, I think we'll probably target M67 for this instead.
I'll take a look.
Cc: altimin@chromium.org
+altimin

chrishtr@ - could you confirm the following:
1. "not getting *lifecycle updates* in background tabs" refers to these states:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/DocumentLifecycle.h?l=49 
(sorry "lifecycle" is super overloaded in Blink)

2. which blink task queues (types) contain these lifecycle tasks? or where do they get queued? (posttask call will give a hint)

3. For the autofocus task is question - I think this is the one? https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/Document.cpp?l=6943
If so, it is getting scheduled on the pauseable task-queue (task type: user-interaction)
There should be no throttling here that I'm aware of for background.
altimin@ -- any other ideas?   
Cc: panicker@chromium.org
Owner: chrishtr@chromium.org
over to chrishtr to answer above questions, then we can look at this from scheduler side.
Owner: panicker@chromium.org
I mean that LocalFrameView::UpdateAllLifecyclePhases is not getting called for the
OOPIFed child.

The autofocus task is getting scheduled.

LocalFrameView::ScheduleAnimation is in fact getting called, which ends up calling
SetNeedsAnimate on the proxy.


Owner: altimin@chromium.org
altimin - could you take a look from scheduler side as why LocalFrameView::UpdateAllLifecyclePhases is not getting called in background?

Comment 21 by creis@chromium.org, Apr 26 2018

altimin@: Friendly ping.  Would you be able to take a look per comment 20?  We'd like to make sure that LocalFrameView::UpdateAllLifecyclePhases is working for OOPIFs.

Comment 22 by creis@chromium.org, May 10 2018

Cc: haraken@chromium.org skyos...@chromium.org
skyostil@ or haraken@, can you help with comment 20 while altimin@ is OOO?  Thanks!
Lifecycle updates are driven by BeginFrames, which are completely paused for background tabs for efficiency reasons, so I think that part is working as expected here. The lifecycle update should happen when the tab is foregrounded again. Is that not happening here?
Re #23: that is correct, the OOPIF is not receiving a BeginFrame after
being foregrounded.

Comment 25 by creis@chromium.org, May 24 2018

Labels: -Target-67 Target-69
Friendly ping.  What's the next step towards fixing this?  Is there a BeginFrame fix needed?  Thanks!
Cc: bokan@chromium.org
Another friendly ping on this.
altimin@ what's the next step here?
Ping: this is marked as a P1, is there an update?

creis@: I can't repro this in 68.0.3440.106 - is this fixed?
(Just getting back from OOO.)  I can still repro this using the original steps on 68.0.3440.106 and 70.0.3534.0 on Windows, so this is not fixed.  bokan@, which platform were you testing on?  I'm curious why it didn't repro for you.

Is there anyone that can help with this, if altimin@ doesn't have the bandwidth?
Owner: skyos...@chromium.org
Sami could you triage?
Hmm, maybe I did something wrong - I can now repro with Linux 70.0.3528.4. Maybe I missed the flag or something. 

Sign in to add a comment