Fix: Streaming stops working after device sleep/wake#33
Merged
Conversation
Owner
|
thank you so much man, i have been busy with ur exams and appreciate ur updates, thank you so much for fixing issues :D |
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.
Fix: Streaming stops working after device sleep/wake
Problem
After putting the device to sleep and waking it up, the Hyperion LEDs would stop responding even though the app UI showed streaming as active.
Root cause
The Hyperion FlatBuffers client kept the TCP socket open during sleep. On wake the encoder was still running its capture loop, but Hyperion's priority source had been removed server-side because no new image data was received. The previous approach of calling
clearLights()on screen off — which sent an explicit Clear command over the socket — was racing with in-flightsetImage()calls on the same non-thread-safeFlatBufferBuilder, producing corrupted frames that Hyperion discarded, leaving the LEDs permanently off until the app was restarted.Solution
Clean pause on screen off, clean reconnect on screen on.
ACTION_SCREEN_OFF→ stop the capture loop (pauseRecording) + close the socket (pauseConnection)ACTION_SCREEN_ON→ open a fresh socket (resumeConnection) + restart the capture loop (resumeRecording)The
VirtualDisplayandImageReaderare kept alive across sleep so no MediaProjection permission prompt is shown on wake.Changes
HyperionThread.ktpauseConnection(): cancels any pending frame task, closes the socket, clearsclientRef— leaves the executor running so it's ready for reconnectresumeConnection(): submits a newcreateClient()call on the executor; firesonConnected()on successHyperionScreenEncoder.java/HyperionScreenEncoderBase.javapauseRecording()(abstract in base, implemented in encoder): stops the capture runnable and setsmRunning = falsewithout releasing theVirtualDisplayorImageReaderHyperionScreenService.javaACTION_SCREEN_OFF: replacedclearLights()withpauseRecording()+pauseConnection()ACTION_SCREEN_ON: replaced the stale!isCapturing()guard with unconditionalresumeConnection()+resumeRecording()Tested on Shield 2017 with Android 11