Bug 186216 - ServicesOverlayController can hold references to Documents after you navigate away
Summary: ServicesOverlayController can hold references to Documents after you navigate...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-06-01 17:50 PDT by Simon Fraser (smfr)
Modified: 2022-02-09 10:46 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2018-06-01 17:50:20 PDT
ServiceOverlayController::Highlight() has a Ref<Range>, and Range has a Ref<Document>.

When you change the selection in a view, ServiceOverlayController makes a “potential highlight” Highlight, which retains the Document. If you then navigate, there’s nothing that clears that Highlight, until the selection changes.

We need to either have ServiceOverlayController use weak refs, or clear its highlights on navigation.
Comment 1 Simon Fraser (smfr) 2018-06-01 17:50:34 PDT
rdar://problem/40735219
Comment 2 Simon Fraser (smfr) 2018-06-01 17:51:54 PDT
This is visible with any layout test that makes a selection (like LayoutTests/fast/css/counters/counter-after-style-crash.html) and the patch in bug 186214
Comment 3 Wenson Hsieh 2022-02-09 10:46:45 PST
(In reply to Simon Fraser (smfr) from comment #0)
> ServiceOverlayController::Highlight() has a Ref<Range>, and Range has a
> Ref<Document>.
> 
> When you change the selection in a view, ServiceOverlayController makes a
> “potential highlight” Highlight, which retains the Document. If you then
> navigate, there’s nothing that clears that Highlight, until the selection
> changes.
> 
> We need to either have ServiceOverlayController use weak refs, or clear its
> highlights on navigation.

We should probably add logic to clear state underneath `Document::willBeRemovedFromFrame()` (similar to how some of the other controller-type objects have a `documentDetached` method).