Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebCodecs] Mark SharedWorker as unsupported in serialization. #38351

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions webcodecs/videoFrame-serialization.crossAgentCluster.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
};
</script>
<script id='sharedWorkerCode' type='javascript/worker'>
let received = new Map();
self.onconnect = function (event) {
const port = event.ports[0];
port.onmessage = function (e) {
let frame = e.data.frame;
if (e.data.transfer) {
port.postMessage(frame, [frame]);
} else {
port.postMessage(frame);
if (e.data.hasOwnProperty('id')) {
port.postMessage(
received.get(e.data.id) ? 'RECEIVED' : 'NOT_RECEIVED');
return;
}
if (e.data.toString() == '[object VideoFrame]') {
received.set(e.data.timestamp, e.data);
}
};
};
Expand Down Expand Up @@ -70,12 +73,12 @@
const worker = new SharedWorker(window.URL.createObjectURL(blob));
let frame = createVideoFrame(40);
worker.port.postMessage({frame: frame, transfer: false});
worker.port.postMessage({'id': 40});
const received = await new Promise(resolve => worker.port.onmessage = e => {
resolve(e.data);
});
assert_equals(received.toString(), '[object VideoFrame]');
assert_equals(received.timestamp, 40);
}, 'Verify frames can be passed back and forth between main and sharedworker');
assert_equals(received, 'NOT_RECEIVED');
}, 'Verify frames cannot be passed to sharedworker');

promise_test(async () => {
navigator.serviceWorker.register('videoFrame-serialization.crossAgentCluster.serviceworker.js');
Expand Down Expand Up @@ -124,12 +127,12 @@
const worker = new SharedWorker(window.URL.createObjectURL(blob));
let frame = createVideoFrame(90);
worker.port.postMessage({frame: frame, transfer: true});
worker.port.postMessage({'id': 90});
const received = await new Promise(resolve => worker.port.onmessage = e => {
resolve(e.data);
});
assert_equals(received.toString(), '[object VideoFrame]');
assert_equals(received.timestamp, 90);
}, 'Verify frames can be transferred back and forth between main and sharedworker');
assert_equals(received, 'NOT_RECEIVED');
}, 'Verify frames cannot be transferred to a sharedworker');

promise_test(async () => {
navigator.serviceWorker.register('videoFrame-serialization.crossAgentCluster.serviceworker.js');
Expand Down