feat: Implement improved side effects cleaning#34
Open
benjaminrobinet wants to merge 2 commits into
Open
Conversation
|
@benjaminrobinet is attempting to deploy a commit to the plutotcool Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
Thanks, can you add tests for the new behaviors introduced by these changes ? |
Contributor
Author
|
Done @juliendargelos :) |
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.
I faced some performance issues after few Renderer creation / closing.
Tried to improve it a bit. Might contain some AI slope.
Summary
Cancellable stream loop —
Demuxer.demuxStreamnow returns acancel()function. Calling it stops the background read loop, cancels the underlying reader, and rejects any pendingloaded()promises. Previously the loop ran to completion regardless of whether the consumer was still alive.Decoder tears down its stream on close —
Decoderstores thecancelfromdemuxStreamand calls it inclose()(and before starting a newloadStream). TheonLoadFramescallback and all frame callbacks guard againstclosed, so no frames are processed and noVideoDecoderis touched after teardown.No more VideoDecoder resurrection —
TrackDecoder.set()now returns immediately when closed instead of reconfiguring a closedVideoDecoder.TrackDecoder.load()re-creates the decoder lazily when reloading after a close, keeping theload → close → loadcycle working.output()also guards against being called post-close.Complete and idempotent
Renderer.close()— The VAO is now deleted, all GL handles are nulled after deletion, andWEBGL_lose_context.loseContext()is called to immediately free the WebGL2 context slot (browsers cap active contexts at ~8–16; exceeding this caused the freezing).close()is safe to call multiple times. Public methods (load,loadStream,seek,progress,set,initialize) throw'Renderer is closed'after teardown.