swiftwasm / JavaScriptKit

Swift framework to interact with JavaScript through WebAssembly.
https://swiftpackageindex.com/swiftwasm/JavaScriptKit/main/documentation/javascriptkit
MIT License
664 stars 44 forks source link

JSClosure will be overriden from other closure #218

Closed sidepelican closed 1 year ago

sidepelican commented 1 year ago

JSClosure stores its identifier and tell it to JS for bridging, but the identifiers has a trouble. hashValue is used for the identifier, but hashValue is not guaranteed to be unique.

https://github.com/swiftwasm/JavaScriptKit/blob/1afbfaf16598119a851dca39e3b447de6cf52589/Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift#L89

j-f1 commented 1 year ago

Hm, good point! Looking at the relevant implementations I think that should be replaced with the UInt(bitPattern:) initializer which can take an ObjectIdentifier.