New issue
Advanced search Search tips

Issue 811414 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 696617
issue 780556



Sign in to add a comment

User activation state in RemoteFrame seems bad for V2

Project Member Reported by mustaq@chromium.org, Feb 12 2018

Issue description

We currently have user activation (user gesture) state stored in the Frame object because we wanted to preserve the old sticky state we used to have as Frame::DocumentHasReceivedUserGesture.

While trying to update LocalFrame vs RemoteFrame implementation diffs for  Issue 780556 , we discovered that there is only a single user of the RemoteFrame's state:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/frame/RemoteFrame.cpp?rcl=bef56b40a4aa9461aa8565e1d4c5311495fa42fb&l=67
which can pull the activation state from its (LocalFrame) callers instead of checking the RemoteFrame's state.

In fact, pulling the state from LocalFrame is more logical since the LocalFrame really own the state: if user interacted with a RemoteFrame, it is the corresponding LocalFrame object that owns the activation, not the shadow "RemoteFrame" in some other renderer's frame tree.

 

Comment 1 by mustaq@chromium.org, Feb 12 2018

Blocking: 696617 780556
Project Member

Comment 2 by bugdroid1@chromium.org, Feb 14 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/88fcb3a6899d77b64195423333ad81a00803f997

commit 88fcb3a6899d77b64195423333ad81a00803f997
Author: Mustaq Ahmed <mustaq@google.com>
Date: Wed Feb 14 16:20:06 2018

Move user activation check to RemoteFrame::Navigate's callers.

Currently RemoteFrame::Navigate is the user of
Frame::HasTransientUserActivation that passes a RemoteFrame*, and
it seems wrong because the user activation (user gesture) needed by
the navigation should belong to the LocalFrame that initiated the
navigation.

Follow-up CLs after this one will update UserActivation code in
Frame to take a LocalFrame* instead of a Frame*, and get rid of
redundant IPCs.

Bug:  811414 
Change-Id: I771c1694043edb54374a44213d16715d9c7da704
Reviewed-on: https://chromium-review.googlesource.com/914736
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536728}
[modify] https://crrev.com/88fcb3a6899d77b64195423333ad81a00803f997/third_party/WebKit/Source/core/frame/RemoteFrame.cpp
[modify] https://crrev.com/88fcb3a6899d77b64195423333ad81a00803f997/third_party/WebKit/Source/core/html/forms/HTMLFormElement.cpp
[modify] https://crrev.com/88fcb3a6899d77b64195423333ad81a00803f997/third_party/WebKit/Source/core/page/DragController.cpp

Comment 3 by mustaq@chromium.org, Feb 14 2018

Cc: mlamouri@chromium.org
Looks like we have two other users of RemoteFrame's user activation:

[A] WebFrame::Swap() which seems like an indirect user (merely a setter):
  https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/exported/WebFrame.cpp?rcl=0f8cefda01ab4f2281e11da181d863a342ebc51d&l=129

[B] AutoplayPolicy's HasBeenActivated() checks all ancestor frames of a given LocalFrame, which contradicts the assumption we made for subframe visibility of UserActivationV2.  Yikes!
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp?rcl=226e3d9e2242c82571ee6f5a7c1a0319cf1a90af&l=79

mlamouri@:  What am I missing for [B]?  May be this is V1 specific?

Comment 4 by mustaq@chromium.org, Feb 14 2018

Oh, just realized re [B] that this is about sticky frame state so old vs new UserActivation doesn't make a difference.  Also the ancestry check is because of that particular FP.

Re the use of RemoteFrame in [B], I see in the design doc link below that the goal is to check all ancestor frames:
https://docs.google.com/document/d/1EH7qZatVnTXsBGvQc_53R97Z0xqm6zRblKg3eVmNp30/edit#heading=h.l5cxp223oy0l
so just checking the state in an ancestor RemoteFrame doesn't help because if that RemoteFrame's corresponding LocalFrame had seen a user gesture, the info didn't reach the RemoteFrame.  In other words, this is not ready for OOPIFs.

Comment 5 by mustaq@chromium.org, Feb 16 2018

Summary: User activation state in RemoteFrame seems bad for V2 (was: User activation state in RemoteFrame seems unnecessary)
Here is an informed explanation of [B]: it relies on replication of a LocalFrame's user activation state to all corresponding RemoteFrames.
https://cs.chromium.org/chromium/src/content/browser/frame_host/render_frame_host_manager.cc?rcl=980bc8e740e7aa845a18f18f0f2cdf5f4ce4c45c&l=758

This "expensive" replication, triggered through Frame::NotifyUserActivation makes reading the states easy, w/o hopping back to browser process.

While this is correct, it could be worse for UserActivationV2 for more involved tree state update, so we will switch to "easy write" and "expensive read".  I will outline the details in a design doc.

Status: Fixed (was: Assigned)
The crack we currently have with autoplay feature policy will be fixed through  Issue 780556 , without removing RemoteFrame states.

We need no more cleanups here.  See the design doc in  Issue 780556 : we have a design for v2 state propagation across frames where RemoteFrame states serve as a cache to ease state "reading" cost.

Sign in to add a comment