Bug 212714 - Release Assert @ WebCore::RenderTreeBuilder::RenderTreeBuilder
Summary: Release Assert @ WebCore::RenderTreeBuilder::RenderTreeBuilder
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
: 211800 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-06-03 13:33 PDT by Pinki Gyanchandani
Modified: 2020-08-26 22:58 PDT (History)
15 users (show)

See Also:


Attachments
Patch (6.69 KB, patch)
2020-06-03 13:44 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (6.75 KB, patch)
2020-06-03 15:42 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (2.46 KB, patch)
2020-06-08 14:38 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (2.56 KB, patch)
2020-06-09 13:54 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (2.28 KB, patch)
2020-06-09 16:42 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (2.32 KB, patch)
2020-06-10 12:40 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (1.68 KB, patch)
2020-06-10 16:20 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (2.59 KB, patch)
2020-06-10 23:34 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (2.70 KB, patch)
2020-06-12 17:02 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pinki Gyanchandani 2020-06-03 13:33:56 PDT
Release Assert @ WebCore::RenderTreeBuilder::RenderTreeBuilder
Comment 1 Pinki Gyanchandani 2020-06-03 13:44:53 PDT
Created attachment 400966 [details]
Patch
Comment 2 Geoffrey Garen 2020-06-03 13:55:31 PDT
Comment on attachment 400966 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=400966&action=review

> Source/WebCore/ChangeLog:8
> +        Widget Removal in middle of building a Render Tree causes side effects, leading to Release Assert. Moved the scope for suspension of widgets

Removal => removal

in middle => in the middle

> Source/WebCore/ChangeLog:9
> +        update to RenderTreeBuilder instead of having it at RenderTreeUpdater. 

at RenderTreeUpdater => in RenderTreeUpdater

> Source/WebCore/ChangeLog:11
> +        Also made sure that the WidgetHierarchyUpdatesSuspensionScope::moveWidgets(), should handle all widgets scheduled for move. 

WidgetHierarchyUpdatesSuspensionScope::moveWidgets(), => WidgetHierarchyUpdatesSuspensionScope::moveWidgets()

scheduled for move. => scheduled to move, including new widgets scheduled during moveWidgets().

> Source/WebCore/rendering/updating/RenderTreeBuilder.h:66
> +    WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;

WebKit style puts data members together at the end of the class definition, and prefixes data members with "m_". 

I would put this declaration right above "RenderView& m_view" and call it "WidgetHierarchyUpdatesSuspensionScope m_widgetHierarchyUpdatesSuspensionScope".
Comment 3 Pinki Gyanchandani 2020-06-03 15:42:10 PDT
Created attachment 400972 [details]
Patch
Comment 4 Pinki Gyanchandani 2020-06-03 15:44:36 PDT
rdar://problem/63494588
Comment 5 Geoffrey Garen 2020-06-03 16:08:02 PDT
Comment on attachment 400972 [details]
Patch

r=me
Comment 6 EWS 2020-06-03 16:22:44 PDT
Committed r262524: <https://trac.webkit.org/changeset/262524>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 400972 [details].
Comment 7 Jason Lawrence 2020-06-05 13:44:22 PDT
Reverted r262524 for reason:

Reverting because this commit may have caused issues with other tests.

Committed r262651: <https://trac.webkit.org/changeset/262651>
Comment 8 Pinki Gyanchandani 2020-06-08 14:38:05 PDT
Created attachment 401374 [details]
Patch
Comment 9 Geoffrey Garen 2020-06-08 14:44:17 PDT
Comment on attachment 401374 [details]
Patch

r=me
Comment 10 Geoffrey Garen 2020-06-08 14:44:47 PDT
We are re-landing this patch in pieces to see if the mysterious occasional bot failure re-surfaces, and if so, which part of the patch triggers it.
Comment 11 EWS 2020-06-08 15:14:55 PDT
Committed r262743: <https://trac.webkit.org/changeset/262743>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401374 [details].
Comment 12 Pinki Gyanchandani 2020-06-09 11:44:52 PDT
Last submitted code changes have worked fine. No regression is observed.

Re-opening to land the test next to determine, if test was the cause of regression
Comment 13 Pinki Gyanchandani 2020-06-09 13:54:41 PDT
Created attachment 401471 [details]
Patch
Comment 14 Pinki Gyanchandani 2020-06-09 13:56:01 PDT
Comment on attachment 401471 [details]
Patch

Re-landing the test, to check if test triggers bot failures.
Comment 15 Pinki Gyanchandani 2020-06-09 16:42:01 PDT
Created attachment 401494 [details]
Patch
Comment 16 Pinki Gyanchandani 2020-06-09 16:43:18 PDT
Comment on attachment 401494 [details]
Patch

Re-landing second code change to see if this will result into any regression, seen earlier.
Comment 17 Geoffrey Garen 2020-06-09 21:00:09 PDT
Comment on attachment 401494 [details]
Patch

r=me
Comment 18 EWS 2020-06-09 21:16:17 PDT
Committed r262835: <https://trac.webkit.org/changeset/262835>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401494 [details].
Comment 19 Darin Adler 2020-06-10 10:06:11 PDT
Comment on attachment 401494 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401494&action=review

> Source/WebCore/rendering/RenderWidget.cpp:60
> +        auto map = WTFMove(widgetNewParentMap());

In cases like this where we *rely* in the behavior that the source ends up empty afterward, instead of just allowing move as an optimization, we should write using std::exchange instead.

    auto map = std::exchange(widgetNewParentMap(), { });

The WTFMove form allows move as an optimization, but also allows the source map to have a remnant value other than empty. The std::exchange form guarantees that the source map will be empty. Both should generate nearly identical code if all the optimization is working properly.
Comment 20 Pinki Gyanchandani 2020-06-10 12:25:41 PDT
Re-opening to incorporate Darin's comment -

replacing auto map = WTFMove(widgetNewParentMap()) with auto map = std::exchange(widgetNewParentMap(), { }).
Comment 21 Pinki Gyanchandani 2020-06-10 12:40:13 PDT
Created attachment 401570 [details]
Patch
Comment 22 Pinki Gyanchandani 2020-06-10 13:46:18 PDT
should have updated webkit after Committ r262835: to make the new change. correcting it
Comment 23 Pinki Gyanchandani 2020-06-10 16:20:50 PDT
Created attachment 401599 [details]
Patch
Comment 24 Geoffrey Garen 2020-06-10 16:34:03 PDT
Comment on attachment 401599 [details]
Patch

r=me
Comment 25 Geoffrey Garen 2020-06-10 16:34:46 PDT
> > Source/WebCore/rendering/RenderWidget.cpp:60
> > +        auto map = WTFMove(widgetNewParentMap());
> 
> In cases like this where we *rely* in the behavior that the source ends up
> empty afterward, instead of just allowing move as an optimization, we should
> write using std::exchange instead.
> 
>     auto map = std::exchange(widgetNewParentMap(), { });
> 
> The WTFMove form allows move as an optimization, but also allows the source
> map to have a remnant value other than empty. The std::exchange form
> guarantees that the source map will be empty. Both should generate nearly
> identical code if all the optimization is working properly.

+Chris because I think he has an opinion on move producing an empty value.
Comment 26 Chris Dumez 2020-06-10 16:48:02 PDT
(In reply to Geoffrey Garen from comment #25)
> > > Source/WebCore/rendering/RenderWidget.cpp:60
> > > +        auto map = WTFMove(widgetNewParentMap());
> > 
> > In cases like this where we *rely* in the behavior that the source ends up
> > empty afterward, instead of just allowing move as an optimization, we should
> > write using std::exchange instead.
> > 
> >     auto map = std::exchange(widgetNewParentMap(), { });
> > 
> > The WTFMove form allows move as an optimization, but also allows the source
> > map to have a remnant value other than empty. The std::exchange form
> > guarantees that the source map will be empty. Both should generate nearly
> > identical code if all the optimization is working properly.
> 
> +Chris because I think he has an opinion on move producing an empty value.

I indeed prefer if our move constructors leave the object empty and clean to reduce the change of bugs. We've had a lot of bugs like that in the past. This makes adopting of std::optional a bit controversial because its move constructor leaves the optional in a bad state.

That said, I am all for using std::exchange() instead of WTFMove() when we know we are going to re-use the value after. It is the proper C++ way and I think we should enforce it in new code. It would make a switch to std::optional some day easier too although I have concerns about that part :)
Comment 27 Darin Adler 2020-06-10 16:57:07 PDT
Exactly. This use of std::exchange is something Chris and I agree on! We are still debating whether to ever move from WTF::Optional to std::optional; a related but distinct topic.

For what it’s worth, my patch to use std::optional did not show any failures in EWS regression tests, but that doesn’t prove whether or not it introduces bugs that were not detected by those tests.
Comment 28 EWS 2020-06-10 17:10:36 PDT
Committed r262877: <https://trac.webkit.org/changeset/262877>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401599 [details].
Comment 29 Pinki Gyanchandani 2020-06-10 23:19:07 PDT
re-opening to commit the test again  to check if test is the actual cause of bot failure
Comment 30 Pinki Gyanchandani 2020-06-10 23:34:43 PDT
Created attachment 401623 [details]
Patch
Comment 31 EWS 2020-06-11 10:52:03 PDT
Committed r262909: <https://trac.webkit.org/changeset/262909>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401623 [details].
Comment 32 Ryan Haddad 2020-06-11 12:57:04 PDT
Reverted r262909 for reason:

This test causes macOS WK1 tests to intermittently exit early

Committed r262919: <https://trac.webkit.org/changeset/262919>
Comment 33 Pinki Gyanchandani 2020-06-11 16:30:46 PDT
closing this ticket and corresponding radar rdar://problem/63494588 as the code changes are working fine. Its the test case which is causing regression in bots. 
Need to debug test and along with tool dumprendertree to figure out reason of failure.
A separate bug would be created for the same.
Comment 34 Pinki Gyanchandani 2020-06-12 16:58:12 PDT
Re-opening to land the modified test.
Comment 35 Pinki Gyanchandani 2020-06-12 17:02:25 PDT
Created attachment 401808 [details]
Patch
Comment 36 Alexey Proskuryakov 2020-06-12 17:56:28 PDT
Comment on attachment 401808 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401808&action=review

> LayoutTests/fast/rendering/widget-removal-in-render-tree-builder-crash.html:38
> +<details id="z" open="true" ontoggle="runTest()">a</details>

I am still very skeptical of running test JS in the middle of parsing. Not blocking review, but this could be worth some more effort.
Comment 37 Geoffrey Garen 2020-06-14 16:41:50 PDT
Comment on attachment 401808 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401808&action=review

r=me

>> LayoutTests/fast/rendering/widget-removal-in-render-tree-builder-crash.html:38
>> +<details id="z" open="true" ontoggle="runTest()">a</details>
> 
> I am still very skeptical of running test JS in the middle of parsing. Not blocking review, but this could be worth some more effort.

Pinki, can you test whether this test still fails without your patch if you move the call to runTest() into the window load event?
Comment 38 EWS 2020-06-14 16:45:08 PDT
Committed r263015: <https://trac.webkit.org/changeset/263015>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401808 [details].
Comment 39 Pinki Gyanchandani 2020-06-15 14:41:47 PDT
(In reply to Geoffrey Garen from comment #37)
> Comment on attachment 401808 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=401808&action=review
> 
> r=me
> 
> >> LayoutTests/fast/rendering/widget-removal-in-render-tree-builder-crash.html:38
> >> +<details id="z" open="true" ontoggle="runTest()">a</details>
> > 
> > I am still very skeptical of running test JS in the middle of parsing. Not blocking review, but this could be worth some more effort.
> 
> Pinki, can you test whether this test still fails without your patch if you
> move the call to runTest() into the window load event?

I tried to call runTest with window load event, but then crash is not reproduced, which means the test is meant to be calling runTest in middle of parsing.

Since the test is not causing any regression in bots, will not make any further changes in the code.
Comment 40 Ryosuke Niwa 2020-08-26 22:58:27 PDT
*** Bug 211800 has been marked as a duplicate of this bug. ***