Bug 179849 - downcast to WebKit::FullscreenClient can sometimes fail.
Summary: downcast to WebKit::FullscreenClient can sometimes fail.
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: Jeremy Jones
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-17 16:34 PST by Jeremy Jones
Modified: 2018-05-23 06:43 PDT (History)
4 users (show)

See Also:


Attachments
Patch (2.16 KB, patch)
2017-11-17 16:38 PST, Jeremy Jones
darin: review+
Details | Formatted Diff | Diff
Patch for landing. (2.16 KB, patch)
2017-11-27 13:57 PST, Jeremy Jones
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Jones 2017-11-17 16:34:03 PST
downcast to WebKit::FullscreenClient can sometimes fail.
Comment 1 Jeremy Jones 2017-11-17 16:38:56 PST
Created attachment 327273 [details]
Patch
Comment 2 Darin Adler 2017-11-21 09:06:17 PST
Comment on attachment 327273 [details]
Patch

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

I worry that the issue is deeper than just a bd cast. If _setFullscreenDelegate: does nothing because we are on a different fullscreen client, then the old fullscreen client might be left with the delegate still set. That could be a dangling pointer.

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:4778
>      return nullptr;

I think this should be return nil.
Comment 3 Jeremy Jones 2017-11-27 13:55:41 PST
(In reply to Darin Adler from comment #2)
> Comment on attachment 327273 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=327273&action=review
> 
> I worry that the issue is deeper than just a bd cast. If
> _setFullscreenDelegate: does nothing because we are on a different
> fullscreen client, then the old fullscreen client might be left with the
> delegate still set. That could be a dangling pointer.

The various client objects are owned by the page. When the page clears those clients, those objects and references are destroyed.

Looking over WKWebView, I see the same unsafe pattern that caused this crash also affects the find delegate:

https://bugs.webkit.org/show_bug.cgi?id=180054

> 
> > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:4778
> >      return nullptr;
> 
> I think this should be return nil.

Done.
Comment 4 Jeremy Jones 2017-11-27 13:57:10 PST
Created attachment 327674 [details]
Patch for landing.
Comment 5 WebKit Commit Bot 2017-11-27 14:29:36 PST
Comment on attachment 327674 [details]
Patch for landing.

Clearing flags on attachment: 327674

Committed r225195: <https://trac.webkit.org/changeset/225195>
Comment 6 Frédéric Wang (:fredw) 2018-05-23 06:42:50 PDT
Closing now since patch landed.
Comment 7 Radar WebKit Bug Importer 2018-05-23 06:43:20 PDT
<rdar://problem/40484031>