Closed benjie-git closed 3 months ago
This example is fixed, thank you @PierreQuentel ! But I still see what seems like a related issue. This code:
from browser import window
bcastChannel = window.BroadcastChannel.new("TestChannel")
bcastChannel.postMessage("hi there") # This works. The following should too, but does not.
bcastChannel.postMessage(["hi", "there"])
Throws the error:
File "test.html#__main__", line 4, in <module>
bcastChannel.postMessage(["hi", "there"])
JavascriptError: DataCloneError: Failed to execute 'postMessage' on 'BroadcastChannel': function(self,attr){if(self.__dict__&&$B.$isinstance(self.__dict__,_b_.dict)&&_b_.dict.$contains_string(self.__...<omitted>...)} could not be cloned.
But anything serializable should be valid to send through postMessage()
.
This example is fixed, thank you @PierreQuentel ! But I still see what seems like a related issue. This code:
from browser import window bcastChannel = window.BroadcastChannel.new("TestChannel") bcastChannel.postMessage("hi there") # This works. The following should too, but does not. bcastChannel.postMessage(["hi", "there"])
Throws the error:
File "test.html#__main__", line 4, in <module> bcastChannel.postMessage(["hi", "there"]) JavascriptError: DataCloneError: Failed to execute 'postMessage' on 'BroadcastChannel': function(self,attr){if(self.__dict__&&$B.$isinstance(self.__dict__,_b_.dict)&&_b_.dict.$contains_string(self.__...<omitted>...)} could not be cloned.
But anything serializable should be valid to send through
postMessage()
.
Perhaps related to circular references in the processing of the Array object literal.
This is working great for me now. Thank you again for your responsiveness!
@PierreQuentel - I see a new problem now, starting with this commit: sending a SharedArrayBuffer from the main thread to a worker is broken. It now arrives as an empty object.
logging shows just
{}
instead ofSharedArrayBuffer(8)
I'm afraid testing this is a bit of a pain, as it requires the following headers to be served along with the test page.