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

Changeset 293320 in webkit


Ignore:
Timestamp:
Apr 25, 2022, 4:47:39 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION (249585@main): TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore is timing out
https://bugs.webkit.org/show_bug.cgi?id=239507

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2022-04-25
Reviewed by Wenson Hsieh.

Source/WebKit:

Add purpose-built test interfaces for testing sending IPC::Semaphore via the IPC.

Test: ipc/send-semaphore.html

  • Shared/IPCTester.cpp:

(WebKit::IPCTester::sendSameSemaphoreBack):
(WebKit::IPCTester::sendSemaphoreBackAndSignalProtocol):

  • Shared/IPCTester.h:
  • Shared/IPCTester.messages.in:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm:

Move CanReceiveIPCSemaphore and CanSendIPCSemaphore test logic
to LayoutTests/ipc/send-semaphore.html
The tests were using audio and canvas implementation detail
messages to test that IPC system can send IPC::Semaphore via IPC.
Canvas implementation details changed and the test started
to fail.

The new tests use IPC messages that are purpose-built to test this
feature. The new tests also actually test that the sent semaphores
work.

LayoutTests:

  • ipc/send-semaphore-expected.txt: Added.
  • ipc/send-semaphore.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r293311 r293320  
     12022-04-25  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        REGRESSION (249585@main): TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore is timing out
     4        https://bugs.webkit.org/show_bug.cgi?id=239507
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * ipc/send-semaphore-expected.txt: Added.
     9        * ipc/send-semaphore.html: Added.
     10
    1112022-04-24  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/Source/WebKit/ChangeLog

    r293310 r293320  
     12022-04-25  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        REGRESSION (249585@main): TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore is timing out
     4        https://bugs.webkit.org/show_bug.cgi?id=239507
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Add purpose-built test interfaces for testing sending IPC::Semaphore via the IPC.
     9
     10        Test: ipc/send-semaphore.html
     11
     12        * Shared/IPCTester.cpp:
     13        (WebKit::IPCTester::sendSameSemaphoreBack):
     14        (WebKit::IPCTester::sendSemaphoreBackAndSignalProtocol):
     15        * Shared/IPCTester.h:
     16        * Shared/IPCTester.messages.in:
     17
    1182022-04-24  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Source/WebKit/Shared/IPCTester.cpp

    r292197 r293320  
    3131#include "Decoder.h"
    3232#include "IPCStreamTester.h"
     33#include "IPCTesterMessages.h"
    3334
    3435#include <atomic>
     
    146147}
    147148
     149void IPCTester::sendSameSemaphoreBack(IPC::Connection& connection, IPC::Semaphore&& semaphore)
     150{
     151    connection.send(Messages::IPCTester::SendSameSemaphoreBack(semaphore), 0);
     152}
     153
     154void IPCTester::sendSemaphoreBackAndSignalProtocol(IPC::Connection& connection, IPC::Semaphore&& semaphore)
     155{
     156    IPC::Semaphore newSemaphore;
     157    connection.send(Messages::IPCTester::SendSemaphoreBackAndSignalProtocol(newSemaphore), 0);
     158    if (!semaphore.waitFor(10_s)) {
     159        ASSERT_IS_TESTING_IPC();
     160        return;
     161    }
     162    newSemaphore.signal();
     163    // Wait for protocol commit. Otherwise newSemaphore will be destroyed, and the waiter on the other side
     164    // will fail to wait.
     165    if (!semaphore.waitFor(10_s)) {
     166        ASSERT_IS_TESTING_IPC();
     167        return;
     168    }
     169}
     170
    148171void IPCTester::stopIfNeeded()
    149172{
  • trunk/Source/WebKit/Shared/IPCTester.h

    r292803 r293320  
    7070    void createStreamTester(IPC::Connection&, IPCStreamTesterIdentifier, IPC::StreamConnectionBuffer&&);
    7171    void releaseStreamTester(IPCStreamTesterIdentifier, CompletionHandler<void()>&&);
     72    void sendSameSemaphoreBack(IPC::Connection&, IPC::Semaphore&&);
     73    void sendSemaphoreBackAndSignalProtocol(IPC::Connection&, IPC::Semaphore&&);
    7274
    7375    void stopIfNeeded();
  • trunk/Source/WebKit/Shared/IPCTester.messages.in

    r290505 r293320  
    2828    CreateStreamTester(WebKit::IPCStreamTesterIdentifier identifier, IPC::StreamConnectionBuffer stream) WantsConnection
    2929    ReleaseStreamTester(WebKit::IPCStreamTesterIdentifier identifier) -> () Synchronous
     30
     31    SendSameSemaphoreBack(IPC::Semaphore semaphore) WantsConnection
     32    SendSemaphoreBackAndSignalProtocol(IPC::Semaphore semaphore) WantsConnection
    3033}
    3134
  • trunk/Tools/ChangeLog

    r293318 r293320  
     12022-04-25  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        REGRESSION (249585@main): TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore is timing out
     4        https://bugs.webkit.org/show_bug.cgi?id=239507
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm:
     9        Move CanReceiveIPCSemaphore and CanSendIPCSemaphore test logic
     10        to LayoutTests/ipc/send-semaphore.html
     11        The tests were using audio and canvas implementation detail
     12        messages to test that IPC system can send IPC::Semaphore via IPC.
     13        Canvas implementation details changed and the test started
     14        to fail.
     15
     16        The new tests use IPC messages that are purpose-built to test this
     17        feature. The new tests also actually test that the sent semaphores
     18        work.
     19
    1202022-04-16  Philippe Normand  <philn@igalia.com>
    221
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm

    r291773 r293320  
    287287}
    288288
    289 TEST(IPCTestingAPI, CanReceiveIPCSemaphore)
    290 {
    291     auto webView = createWebViewWithIPCTestingAPI();
    292 
    293     auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);
    294     [webView setUIDelegate:delegate.get()];
    295 
    296     done = false;
    297     auto html = @"<!DOCTYPE html>"
    298         "<script>"
    299         "const bufferSize = 1 << 16;"
    300         "const streamConnection = IPC.createStreamClientConnection('GPU', bufferSize);"
    301         "IPC.sendMessage('GPU', 0, IPC.messages.GPUConnectionToWebProcess_CreateRenderingBackend.name, ["
    302         "    { type: 'RemoteRenderingBackendCreationParameters', 'identifier': 123, 'pageProxyID': IPC.webPageProxyID, 'pageID': IPC.pageID },"
    303         "    { type: 'StreamConnectionBuffer', value: streamConnection.streamBuffer() },"
    304         "]);"
    305         "const arguments = IPC.waitForMessage('GPU', 123, IPC.messages.RemoteRenderingBackendProxy_DidCreateWakeUpSemaphoreForDisplayListStream.name, 100);"
    306         "alert(arguments.length + ':' + arguments[0].type + ':' + arguments[0].value.waitFor(100));"
    307         "</script>";
    308     [webView synchronouslyLoadHTMLString:html];
    309     TestWebKitAPI::Util::run(&done);
    310 
    311     EXPECT_STREQ([alertMessage UTF8String], "1:Semaphore:false");
    312 }
    313 
    314289#endif // ENABLE(GPU_PROCESS)
    315 
    316 TEST(IPCTestingAPI, CanCreateIPCSemaphore)
    317 {
    318     auto webView = createWebViewWithIPCTestingAPI();
    319 
    320     auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);
    321     [webView setUIDelegate:delegate.get()];
    322 
    323     done = false;
    324     [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>alert(IPC.createSemaphore().waitFor(100));</script>"];
    325     TestWebKitAPI::Util::run(&done);
    326 
    327     EXPECT_FALSE([alertMessage boolValue]);
    328 }
    329290
    330291TEST(IPCTestingAPI, CanCreateSharedMemory)
     
    345306    EXPECT_EQ([webView stringByEvaluatingJavaScript:@"sharedMemory.writeBytes(new Int8Array([101, 102, 103, 104, 105, 106]), 2, 3)"].intValue, 0);
    346307    EXPECT_STREQ([webView stringByEvaluatingJavaScript:@"Array.from(new Int8Array(sharedMemory.readBytes())).toString()"].UTF8String, "1,2,101,102,103,32,0,0");
    347 }
    348 
    349 TEST(IPCTestingAPI, CanSendSemaphore)
    350 {
    351     auto webView = createWebViewWithIPCTestingAPI();
    352 
    353     auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);
    354     [webView setUIDelegate:delegate.get()];
    355 
    356     auto* html = @R"HTML(<!DOCTYPE html>
    357 <body>
    358 <script>
    359 const audioContext = new AudioContext;
    360 const destination = audioContext.createMediaStreamDestination();
    361 const semaphore = IPC.createSemaphore();
    362 const result = IPC.sendSyncMessage('GPU', 0, IPC.messages.RemoteAudioDestinationManager_CreateAudioDestination.name, 100,
    363     [{type: 'String', value: 'some device'},
    364     {type: 'uint32_t', value: destination.numberOfInputs},
    365     {type: 'uint32_t', value: destination.channelCount},
    366     {type: 'float', value: audioContext.sampleRate}, {type: 'float', value: audioContext.sampleRate},
    367     {type: 'Semaphore', value: semaphore}]);
    368 alert(result.arguments[0].type);
    369 </script>
    370 </body>)HTML";
    371 
    372     done = false;
    373     [webView synchronouslyLoadHTMLString:html];
    374     TestWebKitAPI::Util::run(&done);
    375 
    376     EXPECT_STREQ([alertMessage UTF8String], "uint64_t");
    377308}
    378309
Note: See TracChangeset for help on using the changeset viewer.