You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Currently, js.Func's are very prone to bugs. Developers have to manually call Release() on allocated js.Func's after they are sure there are no references. But, releasing funcs too early leads to errors when called again from the js side. On the other hand, never releasing funcs (although safer) results in memory leaks.
Unlike OS files, socket connections, and other manually freed resources, the lifetime of js.Func's are sometimes unclear, making them a good candidate for automatic collection.
syscall/js is not covered by the go compatibility promise.
Alternatively, to not break current apps, Func.Release() can be turned into a no-op or work as usual alongside the new auto gc.
Most modern versions of major browsers support FinalizationRegistry, which is the current precedent for implementing changes to the wasm backend (see comment). In the event of incompatibility, the js.Func can be leaked, still allowing the program to run as normally as possible.
The text was updated successfully, but these errors were encountered: