[Webkit-unassigned] [Bug 184285] New: MessagePorts created in WebWorker thread stops working
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Apr 3 19:19:04 PDT 2018
https://bugs.webkit.org/show_bug.cgi?id=184285
Bug ID: 184285
Summary: MessagePorts created in WebWorker thread stops working
Product: WebKit
Version: Safari 11
Hardware: Macintosh
OS: macOS 10.13
Status: NEW
Severity: Normal
Priority: P2
Component: New Bugs
Assignee: webkit-unassigned at lists.webkit.org
Reporter: ycabon at esri.com
Communication between MessagePort instances created in a WebWorker thread stops after time.
I suspect GC happening.
The following test case is in 2 parts. An html page and a worker script.
The worker creates a message channel and transfer one of the ports back to the main thread.
The ports start communicating then after some 18 exchanges, the communication stops.
I finally figured that if I kept the reference of the MessageChannel that create the ports around the problem disappeared.
I looks like this shouldn't happen.
The test cases creates some arraybuffers and discard them to trigger some GC.
Test case:
//---------------------------------------------------------------------------
// messagechannel_garbagecollected.html
//---------------------------------------------------------------------------
<html>
<body>
<script>
var worker = new Worker("./messagechannel_garbagecollected_worker.js");
var arrays = [];
worker.addEventListener("message", (event) => {
var port = event.data.port;
port.addEventListener("message", (event) => {
document.body.innerHTML += event.data + "<br />";
if (arrays.length === 10) {
arrays = [];
}
arrays.push(new ArrayBuffer(500000));
setTimeout(function() {
port.postMessage("ping");
}, 50);
});
port.start();
port.postMessage("ping");
});
</script>
</body>
</html>
//---------------------------------------------------------------------------
// messagechannel_garbagecollected_worker.js
//---------------------------------------------------------------------------
var arrays = [];
function startup() {
var channel = new MessageChannel();
var port = channel.port1;
var id = 0;
port.addEventListener("message", (event) => {
if (arrays.length === 10) {
arrays = [];
}
arrays.push(new ArrayBuffer(50000));
setTimeout(function() {
port.postMessage("pong " + id++);
}, 50);
});
port.start();
// keeping a dummy reference to the channel keeps it working
// port["channel"] = channel;
self.postMessage({
port: channel.port2
}, [channel.port2]);
}
startup();
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180404/7f03818a/attachment-0002.html>
More information about the webkit-unassigned
mailing list