Changeset 245076 in webkit


Ignore:
Timestamp:
May 8, 2019 4:37:59 PM (5 years ago)
Author:
dbates@webkit.org
Message:

[Legacy WebKit] REGRESSION (r238078): Crash in hardwareKeyboardAvailabilityChangedCallback()
https://bugs.webkit.org/show_bug.cgi?id=197724
<rdar://problem/49725959>

Reviewed by Tim Horton.

Speculative fix for race condition. Between the time we receive a kGSEventHardwareKeyboardAvailabilityChangedNotification
notification and when we schedule execution to run on the WebThread the WebView that notification
was for may no longer exist. Take out a weak ptr on the WebView when we receive the notification
and check that we still have it once we are running on the WebThread.

  • WebView/WebHTMLView.mm:

(hardwareKeyboardAvailabilityChangedCallback):

Location:
trunk/Source/WebKitLegacy/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r245072 r245076  
     12019-05-08  Daniel Bates  <dabates@apple.com>
     2
     3        [Legacy WebKit] REGRESSION (r238078): Crash in hardwareKeyboardAvailabilityChangedCallback()
     4        https://bugs.webkit.org/show_bug.cgi?id=197724
     5        <rdar://problem/49725959>
     6
     7        Reviewed by Tim Horton.
     8
     9        Speculative fix for race condition. Between the time we receive a kGSEventHardwareKeyboardAvailabilityChangedNotification
     10        notification and when we schedule execution to run on the WebThread the WebView that notification
     11        was for may no longer exist. Take out a weak ptr on the WebView when we receive the notification
     12        and check that we still have it once we are running on the WebThread.
     13
     14        * WebView/WebHTMLView.mm:
     15        (hardwareKeyboardAvailabilityChangedCallback):
     16
    1172019-05-08  Timothy Hatcher  <timothy@apple.com>
    218
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

    r244471 r245076  
    147147#import <wtf/RunLoop.h>
    148148#import <wtf/SystemTracing.h>
     149#import <wtf/WeakObjCPtr.h>
    149150
    150151#if PLATFORM(MAC)
     
    821822{
    822823    ASSERT(observer);
     824    auto weakWebView = WeakObjCPtr<WebHTMLView>((__bridge WebHTMLView *)observer);
    823825    WebThreadRun(^{
    824         WebHTMLView *webView = (__bridge WebHTMLView *)observer;
    825         if (Frame* coreFrame = core([webView _frame]))
    826             coreFrame->eventHandler().capsLockStateMayHaveChanged();
     826        if (auto webView = weakWebView.get()) {
     827            if (auto* coreFrame = core([webView _frame]))
     828                coreFrame->eventHandler().capsLockStateMayHaveChanged();
     829        }
    827830    });
    828831}
Note: See TracChangeset for help on using the changeset viewer.