mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
c81a3c5242
Summary: The RN Hermes Inspector keeps a mapping of pageId to Connection. This mapping is created in the call to enableDebugging. Later, when disableDebugging is invoked, the inspector will iterate over the pageId to Connection map to find which page to is being disabled. The DecoratedRuntime enables debugging on construction, and disables on destruction. When disabling debugging, the DecoratedRuntime then passes the "naked" hermesRuntime, which in turn gets checked against all connections' runtimes. It turns our that ```HermesExecutorRuntimeAdapter::getRuntime``` returns the runtime **wrapped** by the DecoratedRuntime, and not hermesRuntime itself. This means that no connections match the request for disabling debugging. Which means the Connection never gets deleted, which in turns keep its underlying adapter (in this case, the ```HermesRuntimeExecutorAdapter```) alive, which has a shared_ptr to the runtime wrapped by the DecoratedRuntime. Other than effectively leaking this connection (and thus the runtime), this also causes an issue when the app tries to re-load the page -- at which point the inspector will remove the old entry from the page to connection mapping, thus initiating the destruction of the (leaked) Runtime in a thread other than the thread that created the runtime. Changelog: [Internal] Reviewed By: javache Differential Revision: D37809467 fbshipit-source-id: e73caa357a300a0d48e69aa3a1a8b00a97519f24