Bug 210859

Summary: fast/events/event-handler-detached-document-dispatchEvent.html is crashing
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, jer.noble, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing. none

Description Eric Carlson 2020-04-22 08:43:27 PDT
r260182 causes fast/events/event-handler-detached-document-dispatchEvent.html to crash.
Comment 1 Eric Carlson 2020-04-22 08:43:50 PDT
<rdar://problem/62072269>
Comment 2 Eric Carlson 2020-04-22 08:55:40 PDT
Created attachment 397197 [details]
Patch
Comment 3 Jer Noble 2020-04-22 09:53:22 PDT
Comment on attachment 397197 [details]
Patch

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

r=me, with nit.

> Source/WebCore/html/MediaElementSession.cpp:146
> +    if (m_haveAddedMediaUsageManagerSession)
> +        return;
> +
> +    auto page = m_element.document().page();
> +    if (!page)
> +        return;
> +
> +    page->chrome().client().addMediaUsageManagerSession(mediaSessionIdentifier(), m_element.sourceApplicationIdentifier(), m_element.document().url());
> +    m_haveAddedMediaUsageManagerSession = true;

A smart person once told me <https://bugs.webkit.org/show_bug.cgi?id=210589#c3> that they preferred to set this kind of state before calling the callback to protect against re-entrancy. ;)
Comment 4 Eric Carlson 2020-04-22 10:50:47 PDT
Comment on attachment 397197 [details]
Patch

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

>> Source/WebCore/html/MediaElementSession.cpp:146
>> +    m_haveAddedMediaUsageManagerSession = true;
> 
> A smart person once told me <https://bugs.webkit.org/show_bug.cgi?id=210589#c3> that they preferred to set this kind of state before calling the callback to protect against re-entrancy. ;)

LOL, good point!
Comment 5 Eric Carlson 2020-04-22 10:52:23 PDT
Created attachment 397224 [details]
Patch for landing.
Comment 6 EWS 2020-04-22 12:38:04 PDT
Committed r260529: <https://trac.webkit.org/changeset/260529>

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