⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271479 in webkit


Ignore:
Timestamp:
Jan 13, 2021, 10:31:21 PM (6 years ago)
Author:
timothy_horton@apple.com
Message:

REGRESSION (r266634): Messages crashes sometimes while scrolling around and playing YouTube videos
https://bugs.webkit.org/show_bug.cgi?id=220602
<rdar://problem/70402593>

Reviewed by Wenson Hsieh.

Source/WebKit:

No new tests; we are unable to API test video full-screen because of the lack of UIApp;
I have written a stand-alone test app that can reliably reproduce before this patch
and not afterwards.

  • UIProcess/Cocoa/WebPageProxyCocoa.mm:

(WebKit::WebPageProxy::scheduleActivityStateUpdate):
We can't call dispatchActivityStateChange directly underneath a post-commit callback,
because it has side-effects (like un-parenting the full-screen window) that may result
in other frameworks (e.g. UIKit) trying to install commit handlers for the same phase,
which is not allowed.

To fix this, add a dispatch_async; we _only_ care that the activity state change
doesn't apply until after the active commit is complete.

Tools:

  • TestWebKitAPI/PlatformWebView.h:

Mark PlatformWebView noncopyable, since it is effectively noncopyable
(at least, the macOS implementation will overrelease the view if you
copy it, whoops).

  • TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm:

(TestWebKitAPI::TEST):
Add a matching dispatch_async, or this test fails.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r271477 r271479  
     12021-01-13  Tim Horton  <timothy_horton@apple.com>
     2
     3        REGRESSION (r266634): Messages crashes sometimes while scrolling around and playing YouTube videos
     4        https://bugs.webkit.org/show_bug.cgi?id=220602
     5        <rdar://problem/70402593>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        No new tests; we are unable to API test video full-screen because of the lack of UIApp;
     10        I have written a stand-alone test app that can reliably reproduce before this patch
     11        and not afterwards.
     12
     13        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
     14        (WebKit::WebPageProxy::scheduleActivityStateUpdate):
     15        We can't call dispatchActivityStateChange directly underneath a post-commit callback,
     16        because it has side-effects (like un-parenting the full-screen window) that may result
     17        in other frameworks (e.g. UIKit) trying to install commit handlers for the same phase,
     18        which is not allowed.
     19
     20        To fix this, add a dispatch_async; we _only_ care that the activity state change
     21        doesn't apply until after the active commit is complete.
     22
     23
    1242021-01-13  Chris Dumez  <cdumez@apple.com>
    225
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r271469 r271479  
    506506    if (hasActiveCATransaction) {
    507507        [CATransaction addCommitHandler:[weakThis = makeWeakPtr(*this)] {
    508             auto protectedThis = makeRefPtr(weakThis.get());
    509             if (!protectedThis)
    510                 return;
    511 
    512             protectedThis->dispatchActivityStateChange();
     508            // We can't call dispatchActivityStateChange directly underneath this commit handler, because it has side-effects
     509            // that may result in other frameworks trying to install commit handlers for the same phase, which is not allowed.
     510            // So, dispatch_async here; we only care that the activity state change doesn't apply until after the active commit is complete.
     511            dispatch_async(dispatch_get_main_queue(), [weakThis] {
     512                auto protectedThis = makeRefPtr(weakThis.get());
     513                if (!protectedThis)
     514                    return;
     515
     516                protectedThis->dispatchActivityStateChange();
     517            });
    513518        } forPhase:kCATransactionPhasePostCommit];
    514519        return;
  • trunk/Tools/ChangeLog

    r271475 r271479  
     12021-01-13  Tim Horton  <timothy_horton@apple.com>
     2
     3        REGRESSION (r266634): Messages crashes sometimes while scrolling around and playing YouTube videos
     4        https://bugs.webkit.org/show_bug.cgi?id=220602
     5        <rdar://problem/70402593>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * TestWebKitAPI/PlatformWebView.h:
     10        Mark PlatformWebView noncopyable, since it is effectively noncopyable
     11        (at least, the macOS implementation will overrelease the view if you
     12        copy it, whoops).
     13
     14        * TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm:
     15        (TestWebKitAPI::TEST):
     16        Add a matching dispatch_async, or this test fails.
     17
    1182021-01-13  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Tools/TestWebKitAPI/PlatformWebView.h

    r262022 r271479  
    2828
    2929#include <wtf/FastMalloc.h>
     30#include <wtf/Noncopyable.h>
    3031
    3132#if USE(CG)
     
    7071class PlatformWebView {
    7172    WTF_MAKE_FAST_ALLOCATED;
     73    WTF_MAKE_NONCOPYABLE(PlatformWebView);
    7274public:
    7375    explicit PlatformWebView(WKPageConfigurationRef);
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm

    r260366 r271479  
    7676    [wkView endDeferringViewInWindowChanges];
    7777
    78     EXPECT_JS_TRUE(webView.page(), "document.hidden");
     78    __block bool done = false;
     79    WKPageRef page = webView.page();
     80    dispatch_async(dispatch_get_main_queue(), ^{
     81        EXPECT_JS_TRUE(page, "document.hidden");
     82        done = true;
     83    });
     84
     85    Util::run(&done);
    7986}
    8087
Note: See TracChangeset for help on using the changeset viewer.