GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — feat(runtime): interop.keepAliveWhileRetained for natively retained instances by edusperoni · Pull Request #509 · NativeScript/ios Conversation
Collaborator
WhatA natively retained instance of a class built by That refusal is deliberate. It is what lets JS↔ObjC cycles collect, and the doc rules out turning protection into a strong root by default. This PR adds an explicit, per-instance opt-in for the cases where that default is wrong: interop.keepAliveWhileRetained(obj); While MotivationA Blackout console app registers a Firebase App Check provider: a JS-derived How
Trade-offThe opt-in reintroduces exactly what the refusal avoids: a cycle from the native retain back to the instance through JS is never collected. It is meant for delegates and providers that a native framework retains and that nothing they reference retains back. This is documented in the API comment and next to the Known hazard. The structural fix is still the planned move to tracing ( Independent of the husk-diagnostics PR ( Tests
Full suite on a dedicated simulator: 1775 specs, 0 failures. ASan run (
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…nstances * A natively retained instance of a class built by __extends is kept alive by refusing its finalizer (GcProtect is a flag on a weak kFinalizer handle). Everything reachable only through its JS properties is still queued and disposed in the same GC, so the instance comes back holding a husk. interop.keepAliveWhileRetained(obj) opts one instance into a strong handle for exactly as long as it is protected, so V8 traces its properties like any other root. * ObjectManager::SetGcProtected is now the only way the swizzled retain/release change protection; ObjectManager::SyncKeepAliveRoot clears the handle's weakness on protect and re-arms it on unprotect, parking the weak callback's ObjectWeakCallbackState on the ObjCDataWrapper in between. __releaseNativeCounterpart takes that parked state back before resetting the handle, so retiring a kept-alive instance never leaves a strong root behind. * The opt-in is per instance because the strong handle is exactly what the refusal exists to avoid: a cycle from the native retain back to the instance through JS is never collected. Only instances of __extends classes (Caches::RetainTrackedClasses) are accepted; anything else throws a TypeError. * The trade-off is documented next to the known hazard in docs/knowledge/v8-resurrecting-finalizers.md.
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. This branch has not been deployedNo deployments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |