Cleanup the Presentation class when disconnecting the Glasses #1763
+73
−2
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.
We are creating new instances of the VisionGlassPresentation class whenever the device is reconnected to the phone's USB port. This implies that the GLViewTexture we use to render the Wolvic window is recreated as well, hence it uses a different thread than the one used initially to setup the BrowserWorld::instance() singleton. This causes that subsequent calls to the different BrowserWorld native APIs (eg, activityCreated, activityPaused) fail due to the
ASSERT_ON_RENDER_THREAD();
check.The problem is not that the calls made by the VisionGlassPersentation class on the java side are not being performed in the GL thread, but that it's a different thread, as I commented before. It seems that the ASSERT_ON_RENDER_THREAD assertion just checks whether the current thread (pthread_self() ) is the same than the one stored in the BrowserWorld.instance() singleton (m,selfThread).
If we want to avoid restarting the whole app to handle the reconnection use case, we would need to cleanup the BrowserWorld data structures when we detect the disconnection event, so that the subsequent
activityCreated
calls are executed with the new GL thread.Fixes #1764