Bug 237565 - REGRESSION (r290853): CrashTracer: com.apple.WebKit.WebContent.Development at com.apple.WebCore: WebCore::FrameLoader::clear
Summary: REGRESSION (r290853): CrashTracer: com.apple.WebKit.WebContent.Development at...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kate Cheney
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-07 16:19 PST by Kate Cheney
Modified: 2022-03-08 08:57 PST (History)
6 users (show)

See Also:


Attachments
Patch (2.44 KB, patch)
2022-03-07 16:24 PST, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (2.86 KB, patch)
2022-03-07 18:18 PST, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (2.86 KB, patch)
2022-03-08 06:45 PST, Kate Cheney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kate Cheney 2022-03-07 16:19:17 PST
REGRESSION (r290853): CrashTracer: com.apple.WebKit.WebContent.Development at com.apple.WebCore: WebCore::FrameLoader::clear
Comment 1 Kate Cheney 2022-03-07 16:24:36 PST
Created attachment 454048 [details]
Patch
Comment 2 David Kilzer (:ddkilzer) 2022-03-07 16:43:15 PST
Comment on attachment 454048 [details]
Patch

r=me, but might want an expert in FrameLoader code to review this as well.
Comment 3 David Kilzer (:ddkilzer) 2022-03-07 16:44:20 PST
<rdar://89923867>
Comment 4 Chris Dumez 2022-03-07 16:58:41 PST
Comment on attachment 454048 [details]
Patch

I feel it would have been less risky to change the parameter to use a RefPtr<Document>&& instead of a Document*.
Comment 5 Kate Cheney 2022-03-07 18:18:45 PST
Created attachment 454057 [details]
Patch
Comment 6 Chris Dumez 2022-03-07 18:22:38 PST
Comment on attachment 454057 [details]
Patch

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

> Source/WebCore/loader/FrameLoader.cpp:623
> +void FrameLoader::clear(RefPtr<Document> newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView, Function<void()>&& handleDOMWindowCreation)

We should avoid passing parameters my values as much as possible. As suggested on Slack, I think this should be a Ref<Document>&&.

> Source/WebCore/loader/FrameLoader.h:155
> +    void clear(RefPtr<Document> newDocument, bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true, Function<void()>&& handleDOMWindowCreation = nullptr);

ditto.
Comment 7 Chris Dumez 2022-03-07 18:29:54 PST
(In reply to Chris Dumez from comment #6)
> Comment on attachment 454057 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=454057&action=review
> 
> > Source/WebCore/loader/FrameLoader.cpp:623
> > +void FrameLoader::clear(RefPtr<Document> newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView, Function<void()>&& handleDOMWindowCreation)
> 
> We should avoid passing parameters my values as much as possible. As
> suggested on Slack, I think this should be a Ref<Document>&&.
> 
> > Source/WebCore/loader/FrameLoader.h:155
> > +    void clear(RefPtr<Document> newDocument, bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true, Function<void()>&& handleDOMWindowCreation = nullptr);
> 
> ditto.

I looked at the call sites, it doesn't look like any can be updated to "move" the RefPtr in and avoid ref-counting churn. That said, I still think it is good practice to take in a Ref<Document>&& as it could potentially be leveraged in the future and there is no cost/drawback.
Comment 8 Chris Dumez 2022-03-07 19:10:13 PST
Comment on attachment 454057 [details]
Patch

r=me with the change to Ref<>&&
Comment 9 Kate Cheney 2022-03-08 06:41:57 PST
(In reply to Chris Dumez from comment #7)
> (In reply to Chris Dumez from comment #6)
> > Comment on attachment 454057 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=454057&action=review
> > 
> > > Source/WebCore/loader/FrameLoader.cpp:623
> > > +void FrameLoader::clear(RefPtr<Document> newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView, Function<void()>&& handleDOMWindowCreation)
> > 
> > We should avoid passing parameters my values as much as possible. As
> > suggested on Slack, I think this should be a Ref<Document>&&.
> > 
> > > Source/WebCore/loader/FrameLoader.h:155
> > > +    void clear(RefPtr<Document> newDocument, bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true, Function<void()>&& handleDOMWindowCreation = nullptr);
> > 
> > ditto.
> 
> I looked at the call sites, it doesn't look like any can be updated to
> "move" the RefPtr in and avoid ref-counting churn. That said, I still think
> it is good practice to take in a Ref<Document>&& as it could potentially be
> leveraged in the future and there is no cost/drawback.

Ah ok, that's why I ended up not using && but you're right about future leveraging.
Comment 10 Kate Cheney 2022-03-08 06:43:35 PST
(In reply to Chris Dumez from comment #6)
> Comment on attachment 454057 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=454057&action=review
> 
> > Source/WebCore/loader/FrameLoader.cpp:623
> > +void FrameLoader::clear(RefPtr<Document> newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView, Function<void()>&& handleDOMWindowCreation)
> 
> We should avoid passing parameters my values as much as possible. As
> suggested on Slack, I think this should be a Ref<Document>&&.
> 

Assuming you mean RefPtr<Document>&&
Comment 11 Kate Cheney 2022-03-08 06:45:10 PST
Created attachment 454116 [details]
Patch
Comment 12 Chris Dumez 2022-03-08 07:07:55 PST
(In reply to Kate Cheney from comment #10)
> (In reply to Chris Dumez from comment #6)
> > Comment on attachment 454057 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=454057&action=review
> > 
> > > Source/WebCore/loader/FrameLoader.cpp:623
> > > +void FrameLoader::clear(RefPtr<Document> newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView, Function<void()>&& handleDOMWindowCreation)
> > 
> > We should avoid passing parameters my values as much as possible. As
> > suggested on Slack, I think this should be a Ref<Document>&&.
> > 
> 
> Assuming you mean RefPtr<Document>&&

Totally :)
Comment 13 EWS 2022-03-08 08:57:24 PST
Committed r290994 (248172@main): <https://commits.webkit.org/248172@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 454116 [details].