Repository navigation
Restart a plugin whose closed sessions stay stuck in native code - #12
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
A script blocked in native code, such as Node's
execSync,Atomics.waitor a JNI call that never returns, does not noticeScriptEngine.interrupt(). When the host gives up on it and closes the session,EngineEndpoint.close()interrupts and shuts the engine thread down. That thread keeps running, with its whole JavaScript heap, until the process ends. Every such event leaks one more, and in a plugin several projects share they pile up until the process runs out of memory and takes every project down at once.PluginServicenow checks each closed session 10 s after closing it:isStoppedonEngineEndpointandProviderEndpoint, backed byEngineThread.isTerminated), nothing happens;Ending the process is how the host already recovers from a crashed plugin. Since MessengerBotR#275 and #11 it fails what waited at once, counts the crash once for its backoff, and reloads the projects that still use the plugin about 5 s later.
stuckAfterMsandrestartProcessareinternal, so the tests can shorten the wait and observe the restart instead of ending the test process. Additions only:EngineThread.isTerminatedand the twoisStoppedproperties. No wire, protocol or Binder change.Testing
PluginServiceTest:./gradlew :contract:test :android:testDebugUnitTest :tck:test :android:assembleRelease: 98 tests pass. The android suite passed 3 runs in a row.After this is merged I will bump the submodule in MessengerBotR, NodeJSPlugin and PluginFixtures.