-
-
Notifications
You must be signed in to change notification settings - Fork 4
Announce SwiftWasm 5.5.0 and related releases #12
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
Conversation
| Also, in this version of JavaScriptKit we're simplifying the `JSClosure` API. You no longer need to | ||
| release instances of this class manually, they're automatically garbage-collected by the browser | ||
| after your Swift code no longer has any references to them. This is achieved with the new | ||
| `FinalizationRegistry` Web API, for which we had to significantly increase minimum browser versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you note that there is still a cyclic reference issue. e.g.
var button = document.createElement("button")
button.onclick = .object(JSClosure { [button] in
// this capture makes a reference cycle
print(button)
})
┌─> JSObject (button in Swift) -> HTMLElement (button in JS) ────┐
└── JSClosure (onclick in Swift) <─> Closure (onclick in JS) <───┘
In this case, when button element will be disappeared from the main DOM tree, it cannot be deallocated, and the onlick closure will be still referenced. So programmers have to cut the cycle by themselves using weak reference.
So we need to mention that FinalizationRegistry doesn't solve the all GC problem but it only solves dangling closure issue.
j-f1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some grammar nits
Co-authored-by: Jed Fox <git@jedfox.com>
No description provided.