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

Changeset 232156 in webkit


Ignore:
Timestamp:
May 24, 2018, 11:10:05 AM (8 years ago)
Author:
Chris Dumez
Message:

[iOS WK2] Layout Test imported/w3c/web-platform-tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html is a flaky failure
​https://bugs.webkit.org/show_bug.cgi?id=181499
<rdar://problem/36443428>

Reviewed by Youenn Fablet.

Source/WebCore:

After resolving a registration promise, we send an IPC back to the StorageProcess
for synchronization purposes, to make sure the registration does not get updated
before the promise's JS code has been executed. However, resolving a promise
schedules a microtask to run the JS and we would therefore send the IPC back too
early, thus causing flakiness. We now only send the IPC back back only after that
microtask has run and the JS has been executed.

  • bindings/js/JSDOMPromiseDeferred.cpp:

(WebCore::DeferredPromise::callFunction):
(WebCore::DeferredPromise::whenSettled):

  • bindings/js/JSDOMPromiseDeferred.h:
  • workers/service/ServiceWorkerContainer.cpp:

(WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):

LayoutTests:

Unskip test that should no longer be flaky.

  • platform/ios/TestExpectations:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r232155 r232156  
     12018-05-24  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS WK2] Layout Test imported/w3c/web-platform-tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html is a flaky failure
     4        https://bugs.webkit.org/show_bug.cgi?id=181499
     5        <rdar://problem/36443428>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        Unskip test that should no longer be flaky.
     10
     11        * platform/ios/TestExpectations:
     12
    1132018-05-24  Jinho Bang  <zino@chromium.org>
    214
  • trunk/LayoutTests/platform/ios/TestExpectations

    r232107 r232156  
    32683268webkit.org/b/180062 fast/text/user-installed-fonts/shadow-postscript-family.html [ ImageOnlyFailure ]
    32693269
    3270 webkit.org/b/181499 [ Release ] imported/w3c/web-platform-tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html [ Pass Failure ]
    3271 
    32723270webkit.org/b/181838 js/slow-stress/Int32Array-alloc-huge-long-lived.html [ Slow ]
    32733271
  • trunk/Source/WebCore/ChangeLog

    r232155 r232156  
     12018-05-24  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS WK2] Layout Test imported/w3c/web-platform-tests/service-workers/service-worker/update-after-navigation-fetch-event.https.html is a flaky failure
     4        https://bugs.webkit.org/show_bug.cgi?id=181499
     5        <rdar://problem/36443428>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        After resolving a registration promise, we send an IPC back to the StorageProcess
     10        for synchronization purposes, to make sure the registration does not get updated
     11        before the promise's JS code has been executed. However, resolving a promise
     12        schedules a microtask to run the JS and we would therefore send the IPC back too
     13        early, thus causing flakiness. We now only send the IPC back back only after that
     14        microtask has run and the JS has been executed.
     15
     16        * bindings/js/JSDOMPromiseDeferred.cpp:
     17        (WebCore::DeferredPromise::callFunction):
     18        (WebCore::DeferredPromise::whenSettled):
     19        * bindings/js/JSDOMPromiseDeferred.h:
     20        * workers/service/ServiceWorkerContainer.cpp:
     21        (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
     22
    1232018-05-24  Jinho Bang  <zino@chromium.org>
    224
  • trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp

    r231839 r232156  
    5454void DOMPromise::whenSettled(std::function<void()>&& callback)
    5555{
    56     auto& state = *globalObject()->globalExec();
     56    whenPromiseIsSettled(globalObject(), promise(), WTFMove(callback));
     57}
     58
     59void DOMPromise::whenPromiseIsSettled(JSDOMGlobalObject* globalObject, JSC::JSObject* promise, std::function<void()>&& callback)
     60{
     61    auto& state = *globalObject->globalExec();
    5762    auto& vm = state.vm();
    5863    JSLockHolder lock(vm);
    59     auto* handler = JSC::JSNativeStdFunction::create(vm, globalObject(), 1, String { }, [callback = WTFMove(callback)] (ExecState*) mutable {
     64    auto* handler = JSC::JSNativeStdFunction::create(vm, globalObject, 1, String { }, [callback = WTFMove(callback)] (ExecState*) mutable {
    6065        callback();
    6166        return JSC::JSValue::encode(JSC::jsUndefined());
    … …  
    6368
    6469    const JSC::Identifier& privateName = vm.propertyNames->builtinNames().thenPrivateName();
    65     auto* promise = this->promise();
    6670    auto thenFunction = promise->get(&state, privateName);
    6771    ASSERT(thenFunction.isFunction(vm));
  • trunk/Source/WebCore/bindings/js/JSDOMPromise.h

    r228218 r232156  
    5151    Status status() const;
    5252
     53    static void whenPromiseIsSettled(JSDOMGlobalObject*, JSC::JSObject* promise, std::function<void()>&&);
     54
    5355private:
    5456    DOMPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
  • trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp

    r228218 r232156  
    2828
    2929#include "DOMWindow.h"
     30#include "JSDOMPromise.h"
    3031#include "JSDOMWindow.h"
    3132#include <JavaScriptCore/BuiltinNames.h>
    … …  
    6970}
    7071
     72void DeferredPromise::whenSettled(std::function<void()>&& callback)
     73{
     74    DOMPromise::whenPromiseIsSettled(globalObject(), deferred()->promise(), WTFMove(callback));
     75}
     76
    7177void DeferredPromise::reject()
    7278{
  • trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h

    r230764 r232156  
    135135    JSC::JSValue promise() const;
    136136
     137    void whenSettled(std::function<void()>&&);
     138
    137139private:
    138140    DeferredPromise(JSDOMGlobalObject& globalObject, JSC::JSPromiseDeferred& deferred, Mode mode)
    … …  
    145147
    146148    WEBCORE_EXPORT void callFunction(JSC::ExecState&, JSC::JSValue function, JSC::JSValue resolution);
     149
    147150    void resolve(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, deferred()->resolve(), resolution); }
    148151    void reject(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, deferred()->reject(), resolution); }
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp

    r230009 r232156  
    420420    }
    421421
    422     WTF::Function<void()> notifyWhenResolvedIfNeeded = [] { };
     422    std::function<void()> notifyWhenResolvedIfNeeded;
    423423    if (shouldNotifyWhenResolved == ShouldNotifyWhenResolved::Yes) {
    424         notifyWhenResolvedIfNeeded = [connection = m_swConnection, registrationKey = data.key.isolatedCopy()]() mutable {
    425             callOnMainThread([connection = WTFMove(connection), registrationKey = WTFMove(registrationKey)] {
     424        notifyWhenResolvedIfNeeded = [connection = m_swConnection, registrationKey = data.key]() mutable {
     425            callOnMainThread([connection = WTFMove(connection), registrationKey = registrationKey.isolatedCopy()] {
    426426                connection->didResolveRegistrationPromise(registrationKey);
    427427            });
    … …  
    430430
    431431    if (isStopped()) {
    432         notifyWhenResolvedIfNeeded();
     432        if (notifyWhenResolvedIfNeeded)
     433            notifyWhenResolvedIfNeeded();
    433434        return;
    434435    }
    435436
    436437    if (!job.promise()) {
    437         notifyWhenResolvedIfNeeded();
     438        if (notifyWhenResolvedIfNeeded)
     439            notifyWhenResolvedIfNeeded();
    438440        return;
    439441    }
    … …  
    441443    scriptExecutionContext()->postTask([this, protectedThis = makeRef(*this), job = makeRef(job), data = WTFMove(data), notifyWhenResolvedIfNeeded = WTFMove(notifyWhenResolvedIfNeeded)](ScriptExecutionContext& context) mutable {
    442444        if (isStopped() || !context.sessionID().isValid()) {
    443             notifyWhenResolvedIfNeeded();
     445            if (notifyWhenResolvedIfNeeded)
     446                notifyWhenResolvedIfNeeded();
    444447            return;
    445448        }
    … …  
    449452        CONTAINER_RELEASE_LOG_IF_ALLOWED("jobResolvedWithRegistration: Resolving promise for job %" PRIu64 ". Registration ID: %" PRIu64, job->identifier().toUInt64(), registration->identifier().toUInt64());
    450453
     454        if (notifyWhenResolvedIfNeeded) {
     455            job->promise()->whenSettled([notifyWhenResolvedIfNeeded = WTFMove(notifyWhenResolvedIfNeeded)] {
     456                notifyWhenResolvedIfNeeded();
     457            });
     458        }
     459
    451460        job->promise()->resolve<IDLInterface<ServiceWorkerRegistration>>(WTFMove(registration));
    452 
    453         notifyWhenResolvedIfNeeded();
    454461    });
    455462}
Note: See TracChangeset for help on using the changeset viewer.