[selectmenu] Remove re-entrant layout for selectmenu popup positioning [chromium/src : main]

0 views
Skip to first unread message

Dan Clark (Gerrit)

unread,
Sep 23, 2021, 12:29:48 PM9/23/21
to Ionel Popescu, Mason Freed, blink-rev...@chromium.org, blink-...@chromium.org

Attention is currently required from: Ionel Popescu, Mason Freed.

Dan Clark would like Ionel Popescu and Mason Freed to review this change.

View Change

[selectmenu] Remove re-entrant layout for selectmenu popup positioning

HTMLPopupElement::AdjustPopupPositionForSelectMenu uses the
LocalDOMWindow innerWidth/innerHeight getters, which can trigger a
relayout of the current document if viewport is enabled. Since we're
already doing layout at this point, this triggers a CHECK.

Update HTMLPopupElement::AdjustPopupPositionForSelectMenu to get the
size from the LocalFrameView directly such that the recursive
layout recalc is avoided.

Bug: 1121840
Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
---
M third_party/blink/renderer/core/html/html_popup_element.cc
A third_party/blink/web_tests/html/selectmenu/selectmenu-viewport.html
2 files changed, 44 insertions(+), 2 deletions(-)


To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
Gerrit-Change-Number: 3177072
Gerrit-PatchSet: 1
Gerrit-Owner: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-MessageType: newchange

Dan Clark (Gerrit)

unread,
Sep 23, 2021, 12:29:54 PM9/23/21
to blink-rev...@chromium.org, blink-...@chromium.org, Mason Freed, Ionel Popescu, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Ionel Popescu, Mason Freed.

View Change

1 comment:

  • Patchset:

    • Patch Set #1:

      This fixes a crash I was hitting in Android when working on https://chromium-review.googlesource.com/c/chromium/src/+/3138235.

      PTAL, thanks!

      For anyone wondering, the crash stack was:

      FATAL:document.cc(2122)] Check failed: false. We should not re-enter style recalc for the same document
      0018583b logging::CheckError::~CheckError() ../../base/check.cc:106:3
      01599276 blink::Document::UpdateStyleAndLayoutTreeForThisDocument() ../../third_party/blink/renderer/core/dom/document.cc:2122:5
      0184f5aa blink::LocalFrameView::UpdateStyleAndLayoutInternal() ../../third_party/blink/renderer/core/frame/local_frame_view.cc:3336:28
      018488d6 blink::LocalFrameView::UpdateStyleAndLayout() ../../third_party/blink/renderer/core/frame/local_frame_view.cc:3290:21
      01598f52 blink::Document::UpdateStyleAndLayout(blink::DocumentUpdateReason) ../../third_party/blink/renderer/core/dom/document.cc:2483:17
      0180ca21 blink::LocalDOMWindow::GetViewportSize() const ../../third_party/blink/renderer/core/frame/local_dom_window.cc:1355:17
      0180cb20 blink::LocalDOMWindow::innerWidth() const ../../third_party/blink/renderer/core/frame/local_dom_window.cc:1382:43
      019e2498 blink::HTMLPopupElement::AdjustPopupPositionForSelectMenu(blink::ComputedStyle&) ../../third_party/blink/renderer/core/html/html_popup_element.cc:373:29
      019e2418 blink::HTMLPopupElement::CustomStyleForLayoutObject(blink::StyleRecalcContext const&) ../../third_party/blink/renderer/core/html/html_popup_element.cc:356:5
      015e5d3b blink::Element::StyleForLayoutObject(blink::StyleRecalcContext const&) ../../third_party/blink/renderer/core/dom/element.cc:2855:13
      015e6ab1 blink::Element::RecalcOwnStyle(blink::StyleRecalcChange, blink::StyleRecalcContext const&) ../../third_party/blink/renderer/core/dom/element.cc:3151:19
      015e63b6 blink::Element::RecalcStyle(blink::StyleRecalcChange, blink::StyleRecalcContext const&) ../../third_party/blink/renderer/core/dom/element.cc:2948:20
      0153419e blink::StyleEngine::RecalcStyle(blink::StyleRecalcChange, blink::StyleRecalcContext const&) ../../third_party/blink/renderer/core/css/style_engine.cc:2224:16
      01534553 blink::StyleEngine::RecalcStyle() ../../third_party/blink/renderer/core/css/style_engine.cc:2245:3
      015347f6 blink::StyleEngine::UpdateStyleAndLayoutTree() ../../third_party/blink/renderer/core/css/style_engine.cc:2311:7
      01599a6e blink::Document::UpdateStyle() ../../third_party/blink/renderer/core/dom/document.cc:2212:20
      0159942f blink::Document::UpdateStyleAndLayoutTreeForThisDocument() ../../third_party/blink/renderer/core/dom/document.cc:2159:3
      015974ee blink::Document::UpdateStyleAndLayoutTree() ../../third_party/blink/renderer/core/dom/document.cc:2063:3
      0159a48a blink::Document::UpdateStyleAndLayoutTreeForNode(blink::Node const*) ../../third_party/blink/renderer/core/dom/document.cc:2313:3
      019e1b75 blink::HTMLPopupElement::SetFocus() ../../third_party/blink/renderer/core/html/html_popup_element.cc:158:17
      019e18ec blink::HTMLPopupElement::show() ../../third_party/blink/renderer/core/html/html_popup_element.cc:103:3
      01980799 blink::HTMLSelectMenuElement::OpenListbox() ../../third_party/blink/renderer/core/html/forms/html_select_menu_element.cc:331:20
      0198159e blink::HTMLSelectMenuElement::ButtonPartEventListener::Invoke(blink::ExecutionContext*, blink::Event*) ../../third_party/blink/renderer/core/html/forms/html_select_menu_element.cc:745:27
      0161684d blink::EventTarget::FireEventListeners(blink::Event&, blink::EventTargetData*, blink::HeapVector<blink::RegisteredEventListener, 1u>&) ../../third_party/blink/renderer/core/dom/events/event_target.cc:896:15
      0161628c blink::EventTarget::FireEventListeners(blink::Event&) ../../third_party/blink/renderer/core/dom/events/event_target.cc:810:29
      0163ccf0 blink::Node::HandleLocalEvents(blink::Event&) ../../third_party/blink/renderer/core/dom/node.cc:2917:3
      01618b3b blink::NodeEventContext::HandleLocalEvents(blink::Event&) const ../../third_party/blink/renderer/core/dom/events/node_event_context.cc:55:10
      016046dc blink::EventDispatcher::DispatchEventAtBubbling() ../../third_party/blink/renderer/core/dom/events/event_dispatcher.cc:293:21
      0160424f blink::EventDispatcher::Dispatch() ../../third_party/blink/renderer/core/dom/events/event_dispatcher.cc:229:7
      01603d07 blink::EventDispatcher::DispatchSimulatedClick(blink::Node&, blink::Event const*, blink::SimulatedClickCreationScope) ../../third_party/blink/renderer/core/dom/events/event_dispatcher.cc:143:8
      0163d034 blink::Node::DispatchSimulatedClick(blink::Event const*, blink::SimulatedClickCreationScope) ../../third_party/blink/renderer/core/dom/node.cc:2969:3
      019be4d1 blink::HTMLElement::click() ../../third_party/blink/renderer/core/html/html_element.cc:1110:3
      00e13f63 blink::(anonymous namespace)::v8_html_element::ClickOperationCallback(v8::FunctionCallbackInfo<v8::Value> const&) gen/third_party/blink/renderer/bindings/modules/v8/v8_html_element.cc:3701:19
      00d82e9c v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) ../../v8/src/api/api-arguments-inl.h:152:3

To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
Gerrit-Change-Number: 3177072
Gerrit-PatchSet: 1
Gerrit-Owner: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Thu, 23 Sep 2021 16:29:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Ionel Popescu (Gerrit)

unread,
Sep 23, 2021, 12:53:18 PM9/23/21
to Dan Clark, blink-rev...@chromium.org, blink-...@chromium.org, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Dan Clark, Mason Freed.

Patch set 1:Code-Review +1

View Change

1 comment:

To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
Gerrit-Change-Number: 3177072
Gerrit-PatchSet: 1
Gerrit-Owner: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Dan Clark <dan...@microsoft.com>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Thu, 23 Sep 2021 16:53:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Mason Freed (Gerrit)

unread,
Sep 23, 2021, 7:36:05 PM9/23/21
to Dan Clark, blink-rev...@chromium.org, blink-...@chromium.org, Ionel Popescu, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Dan Clark.

Patch set 1:Code-Review +1

View Change

2 comments:

  • Patchset:

    • Patch Set #1:

      LGTM, but see the comment about the test/bug. Thanks!

  • File third_party/blink/web_tests/html/selectmenu/selectmenu-viewport.html:

    • Patch Set #1, Line 26: setViewportEnabled

      I realize that this is likely why this test is a web_test and not a WPT. Is there any way to trigger the bug without this? If not, can you please add a comment in either the CL description or in the test itself explaining that?

      And either way, can you please add a crbug link as a comment inside the test? The bug link in this CL just points back to the <selectmenu> implementation bug, so it'd be great to have a very quick bug filed with the context. (It sounds like this came from a clusterfuzz or something, so hopefully you just have a bug link handy!)

To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
Gerrit-Change-Number: 3177072
Gerrit-PatchSet: 1
Gerrit-Owner: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Dan Clark <dan...@microsoft.com>
Gerrit-Comment-Date: Thu, 23 Sep 2021 23:35:56 +0000

Dan Clark (Gerrit)

unread,
Sep 23, 2021, 7:58:54 PM9/23/21
to blink-rev...@chromium.org, blink-...@chromium.org

Attention is currently required from: Dan Clark.

Dan Clark uploaded patch set #2 to this change.

View Change

[selectmenu] Remove re-entrant layout for selectmenu popup positioning

HTMLPopupElement::AdjustPopupPositionForSelectMenu uses the
LocalDOMWindow innerWidth/innerHeight getters, which can trigger a
relayout of the current document if viewport is enabled. Since we're
already doing layout at this point, this triggers a CHECK.

Update HTMLPopupElement::AdjustPopupPositionForSelectMenu to get the
size from the LocalFrameView directly such that the recursive
layout recalc is avoided.

The test included here is a web_test and not a WPT because the extra
same-document re-layout is only done when viewport is enabled, and
the desktop browser ignores <meta name="viewport">. So the test needs
to use internals.settings to enable viewport instead.

Bug: 1252600

Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
---
M third_party/blink/renderer/core/html/html_popup_element.cc
A third_party/blink/web_tests/html/selectmenu/selectmenu-viewport.html
2 files changed, 44 insertions(+), 2 deletions(-)

To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
Gerrit-Change-Number: 3177072
Gerrit-PatchSet: 2
Gerrit-Owner: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Dan Clark <dan...@microsoft.com>
Gerrit-MessageType: newpatchset

Dan Clark (Gerrit)

unread,
Sep 23, 2021, 8:05:55 PM9/23/21
to blink-rev...@chromium.org, blink-...@chromium.org

Attention is currently required from: Dan Clark.

Dan Clark uploaded patch set #3 to this change.

View Change

[selectmenu] Remove re-entrant layout for selectmenu popup positioning

HTMLPopupElement::AdjustPopupPositionForSelectMenu uses the
LocalDOMWindow innerWidth/innerHeight getters, which can trigger a
relayout of the current document if viewport is enabled. Since we're
already doing layout at this point, this triggers a CHECK.

Update HTMLPopupElement::AdjustPopupPositionForSelectMenu to get the
size from the LocalFrameView directly such that the recursive
layout recalc is avoided.

The test included here is a web_test and not a WPT because the extra
same-document re-layout is only done when viewport is enabled, and
the desktop browser ignores <meta name="viewport">. So the test needs
to use internals.settings to enable viewport instead.

Bug: 1252600
Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
---
M third_party/blink/renderer/core/html/html_popup_element.cc
A third_party/blink/web_tests/html/selectmenu/selectmenu-viewport.html
2 files changed, 44 insertions(+), 2 deletions(-)

To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
Gerrit-Change-Number: 3177072
Gerrit-PatchSet: 3

Dan Clark (Gerrit)

unread,
Sep 23, 2021, 8:06:50 PM9/23/21
to blink-rev...@chromium.org, blink-...@chromium.org, Mason Freed, Ionel Popescu, Chromium LUCI CQ, chromium...@chromium.org

View Change

2 comments:

  • Patchset:

  • File third_party/blink/web_tests/html/selectmenu/selectmenu-viewport.html:

To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
Gerrit-Change-Number: 3177072
Gerrit-PatchSet: 4
Gerrit-Owner: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Fri, 24 Sep 2021 00:06:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
Gerrit-MessageType: comment

Dan Clark (Gerrit)

unread,
Sep 23, 2021, 8:10:17 PM9/23/21
to blink-rev...@chromium.org, blink-...@chromium.org, Mason Freed, Ionel Popescu, Chromium LUCI CQ, chromium...@chromium.org

Patch set 4:Commit-Queue +2

View Change

    To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
    Gerrit-Change-Number: 3177072
    Gerrit-PatchSet: 4
    Gerrit-Owner: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Fri, 24 Sep 2021 00:10:08 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Dan Clark (Gerrit)

    unread,
    Sep 24, 2021, 12:04:45 PM9/24/21
    to blink-rev...@chromium.org, blink-...@chromium.org, Mason Freed, Ionel Popescu, Chromium LUCI CQ, chromium...@chromium.org

    Patch set 4:Commit-Queue +2

    View Change

      To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
      Gerrit-Change-Number: 3177072
      Gerrit-PatchSet: 4
      Gerrit-Owner: Dan Clark <dan...@microsoft.com>
      Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
      Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Comment-Date: Fri, 24 Sep 2021 16:04:36 +0000

      Chromium LUCI CQ (Gerrit)

      unread,
      Sep 24, 2021, 12:58:50 PM9/24/21
      to Dan Clark, blink-rev...@chromium.org, blink-...@chromium.org, Mason Freed, Ionel Popescu, chromium...@chromium.org

      Chromium LUCI CQ submitted this change.

      View Change



      1 is the latest approved patch-set.
      The change was submitted with unreviewed changes in the following files:

      ```
      The name of the file: third_party/blink/web_tests/html/selectmenu/selectmenu-viewport.html
      Insertions: 6, Deletions: 0.

      @@ -23,6 +23,12 @@

      promise_test(async () => {
      if (window.internals) {
      + // Regression test for crbug.com/1252600
      + // On mobile, <meta name="viewport"> can trigger a layout pass when
      + // querying FrameView size. This test ensures that that this doesn't
      + // cause a re-entrant layout when opening the <selectmenu> popup.
      + // Since desktop browsers ignore <meta name="viewport">, set viewport
      + // using internals.settings.
      internals.settings.setViewportEnabled(true);
      internals.settings.setViewportMetaEnabled(true);
      }
      ```

      Approvals: Ionel Popescu: Looks good to me Mason Freed: Looks good to me Dan Clark: Commit
      [selectmenu] Remove re-entrant layout for selectmenu popup positioning

      HTMLPopupElement::AdjustPopupPositionForSelectMenu uses the
      LocalDOMWindow innerWidth/innerHeight getters, which can trigger a
      relayout of the current document if viewport is enabled. Since we're
      already doing layout at this point, this triggers a CHECK.

      Update HTMLPopupElement::AdjustPopupPositionForSelectMenu to get the
      size from the LocalFrameView directly such that the recursive
      layout recalc is avoided.

      The test included here is a web_test and not a WPT because the extra
      same-document re-layout is only done when viewport is enabled, and
      the desktop browser ignores <meta name="viewport">. So the test needs
      to use internals.settings to enable viewport instead.

      Bug: 1252600
      Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
      Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3177072
      Commit-Queue: Dan Clark <dan...@microsoft.com>
      Reviewed-by: Ionel Popescu <iopo...@microsoft.com>
      Reviewed-by: Mason Freed <mas...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#924798}

      ---
      M third_party/blink/renderer/core/html/html_popup_element.cc
      A third_party/blink/web_tests/html/selectmenu/selectmenu-viewport.html
      2 files changed, 50 insertions(+), 2 deletions(-)


      To view, visit change 3177072. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I953822deb9349ff1fca822ced4e032c7a6a47c41
      Gerrit-Change-Number: 3177072
      Gerrit-PatchSet: 5
      Gerrit-Owner: Dan Clark <dan...@microsoft.com>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
      Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-MessageType: merged
      Reply all
      Reply to author
      Forward
      0 new messages