Can a Titanium native module callback fire after its JavaScript Proxy is garbage collected?
0 reputation · 28 Nov 2025, 04:12 UTC
A Titanium native module exposes methods through a JavaScript Proxy object that represents the underlying native instance. When JavaScript invokes a native method asynchronously and supplies a callback, the native side may retain that callback for later invocation.
If the JavaScript garbage collector reclaims the Proxy object while the native operation is still pending, it is unclear whether the bridge keeps the Proxy alive, whether the callback becomes a dangling reference, or whether invocation is silently dropped. Behavior may also differ between iOS and Android because each platform manages the JavaScript engine and native heap separately.
Can a pending native callback safely reference a JavaScript Proxy after the Proxy has been garbage collected? Does the Titanium Bridge automatically root the Proxy for the lifetime of an asynchronous native call, and does this behavior depend on the Titanium SDK version or target platform?