Fix canplay listener and interval accumulation in doUseCamera()#5837
Merged
walterbender merged 2 commits intosugarlabs:masterfrom Mar 8, 2026
Merged
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
vanshika2720
left a comment
There was a problem hiding this comment.
@severe77 Properly stores and removes the canplay listener and clears existing intervals, preventing accumulation without changing original behavior.
optional suggestion (not blocking): after clearInterval, you could set CameraManager.intervalId = null to make the state explicit.
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
|
good eye 👁️ |
Contributor
Author
|
@walterbender the PR is ready for review. Please have a look when you get a chance. |
parthdagia05
pushed a commit
to parthdagia05/musicblocks
that referenced
this pull request
Mar 15, 2026
…rlabs#5837) * Fix canplay listener and interval accumulation in doUseCamera() * Reset CameraManager.intervalId to null after clearInterval
parthdagia05
pushed a commit
to parthdagia05/musicblocks
that referenced
this pull request
Mar 15, 2026
…rlabs#5837) * Fix canplay listener and interval accumulation in doUseCamera() * Reset CameraManager.intervalId to null after clearInterval
1 task
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
This PR fixes accumulation of "canplay" event listeners and setInterval
loops in
doUseCamera()insidejs/utils/utils.js.Problem
Each call to
doUseCamera()attached a new anonymous "canplay" listenerand started a new interval when
isVideowas true.Since the listener reference was not preserved, previously attached
listeners could not be removed. As a result:
setInterval(draw, 100)loops could run simultaneouslySolution
This change:
CameraManager.canPlayHandlerCameraManager.intervalIdThe original logic and behavior are preserved. No refactoring or structural changes were introduced.
Notes
This PR focuses only on preventing listener and interval accumulation.