<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>313692</bug_id>
          
          <creation_ts>2026-04-29 15:38:34 -0700</creation_ts>
          <short_desc>[Site Isolation] postMessage of SharedArrayBuffer doesn&apos;t work in the same process</short_desc>
          <delta_ts>2026-05-05 15:02:17 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Anthony Tarbinian">a.tarbinian</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2206015</commentid>
    <comment_count>0</comment_count>
    <who name="Anthony Tarbinian">a.tarbinian</who>
    <bug_when>2026-04-29 15:38:34 -0700</bug_when>
    <thetext>The following tests are failing with site isolation enabled:

imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/messagechannel.any.html
imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/messagechannel.any.serviceworker.html
imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/messagechannel.any.sharedworker.html
imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/messagechannel.any.worker.html
imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-messagechannel-success.https.html

These test failures involve when postMessage is called to pass a SharedArrayBuffer, 
to another context (i.e. another frame, window, worker). 
See the example JS below:

    const channel = new MessageChannel();
    const sab = new SharedArrayBuffer(16);
    channel.port1.postMessage(sab);

There is an optimization in WebKit to keep the MessagePorts
in a local HashMap (WebMessagePortChannelProvider::m_inProcessPortMessages)
to avoid performing unecessary IPC if the sender and receiver
are in the same process.
See https://commits.webkit.org/255948@main

This optimization caused issues with site isolation enabled
since it&apos;s possible for the target to be in a different process.
The optimization was undone in https://commits.webkit.org/295627@main
Without the optimization, all messages sent over a MessageChannel
are sent over IPC with site isolation enabled.

See the following code in WebMessagePortChannelProvider::postMessageToRemote
which falls back to IPC when the port is not found in m_inProcessPortMessages.
Remote here doesn&apos;t mean a different process, its just the receiver of postMessage.

    void WebMessagePortChannelProvider::postMessageToRemote(MessageWithMessagePorts&amp;&amp; message, const MessagePortIdentifier&amp; remoteTarget)
    {
        auto iterator = m_inProcessPortMessages.find(remoteTarget);
        if (iterator != m_inProcessPortMessages.end()) {
            iterator-&gt;value.append(WTF::move(message));
            WebProcess::singleton().messagesAvailableForPort(remoteTarget);
            return;
        }

        for (auto&amp; port : message.transferredPorts)
            messagePortSentToRemote(port.first);

        protect(networkProcessConnection())-&gt;send(Messages::NetworkConnectionToWebProcess::PostMessageToRemote { message, remoteTarget }, 0);
    }


However, this causes issues for messages which are not serializable over
IPC, such as SharedArrayBuffer which are marked as [NotSerialized]
https://searchfox.org/wubkat/source/Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in#8013

This means that sending a SharedArrayBuffer will fail even when
the sender and receiver are in the same process and there is no 
need to cross IPC.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206016</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-04-29 15:38:39 -0700</bug_when>
    <thetext>&lt;rdar://problem/175890575&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206018</commentid>
    <comment_count>2</comment_count>
    <who name="Anthony Tarbinian">a.tarbinian</who>
    <bug_when>2026-04-29 15:56:34 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/63933</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2207805</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-05-05 15:02:15 -0700</bug_when>
    <thetext>Committed 312641@main (e2355e43e2ef): &lt;https://commits.webkit.org/312641@main&gt;

Reviewed commits have been landed. Closing PR #63933 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>