Bug 166957

Summary: [WK2][Cocoa] Avoid null dereference in Fullscreen code.
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: WebKit2Assignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, eric.carlson, jeremyj-wk, jer.noble
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch eric.carlson: review+

Description Brent Fulgham 2017-01-11 18:01:13 PST
Crash tracing statistics indicate that the 'WebVideoFullScreenManager::didSetupFullscreen' encounters stability issues under certain conditions.

We do not have a reproducible test case showing this behavior, but code inspection indicates that the page values in the completion Block were not being referenced consistently with other methods in the same class. It also did not account for the possibility that the page object had been cleared between starting the dispatch and when the block actually runs.
Comment 1 Brent Fulgham 2017-01-11 18:01:29 PST
<rdar://problem/27745004>
Comment 2 Brent Fulgham 2017-01-11 18:04:18 PST
Created attachment 298649 [details]
Patch
Comment 3 Eric Carlson 2017-01-11 18:08:49 PST
Comment on attachment 298649 [details]
Patch

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

> Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm:333
> +            if (strongThis->m_page)
> +                strongThis->m_page->send(Messages::WebVideoFullscreenManagerProxy::EnterFullscreen(contextId), strongThis->m_page->pageID());

Nit: "strongThis" is only really necessary for the "if". Leaving the second line with implied "this" looks cleaner IMO. It would probably be even better to return early if m_page is NULL.
Comment 4 Brent Fulgham 2017-01-11 21:04:39 PST
Committed r210619: <http://trac.webkit.org/changeset/210619>
Comment 5 Brent Fulgham 2017-01-11 21:06:48 PST
Comment on attachment 298649 [details]
Patch

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

>> Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm:333
>> +                strongThis->m_page->send(Messages::WebVideoFullscreenManagerProxy::EnterFullscreen(contextId), strongThis->m_page->pageID());
> 
> Nit: "strongThis" is only really necessary for the "if". Leaving the second line with implied "this" looks cleaner IMO. It would probably be even better to return early if m_page is NULL.

OK!