OnRuntimeDetach
OnRuntimeDetach is a virtual lifecycle method in the LynxExtensionModule class. It is called when the BTS (Background Thread Script) Runtime is about to be detached from the extension module, typically as part of the LynxView's destruction process.
This callback is always invoked on the BTS thread. It is the correct place to clean up any resources that were allocated or initialized in OnRuntimeAttach or OnRuntimeReady.
Method Signature
Usage
Override this method to perform cleanup tasks related to the JavaScript runtime. This is your last chance to safely interact with N-API handles or other BTS thread-specific resources before they become invalid.
Common use cases include:
- Releasing N-API
napi_refhandles. - Cleaning up data structures that are only used on the BTS thread.
- Finalizing any native modules.
Example
Lifecycle Sequence
The OnRuntimeDetach callback occurs after the main page logic has finished and before the LynxView is fully destroyed.
OnLynxViewDestroyis initiated (UI Thread)OnRuntimeDetachis called (BTS Thread)- ...other cleanup...
Destroyis called (BTS Thread)
See Also
OnRuntimeAttach(): The counterpart to this method.Destroy(): The final cleanup method for the entire module.
Compatibility
LCD tables only load in the browser