Replace Firefox 5s delay with readiness-based initialization#5337
Merged
walterbender merged 2 commits intosugarlabs:masterfrom Feb 7, 2026
Merged
Replace Firefox 5s delay with readiness-based initialization#5337walterbender merged 2 commits intosugarlabs:masterfrom
walterbender merged 2 commits intosugarlabs:masterfrom
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
a878043 to
b2bbdc6
Compare
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Instead of an arbitrary 5-second setTimeout for Firefox, this change introduces a waitForReadiness() function that polls for actual dependency readiness before initializing the app. The new approach: - Polls every animation frame for critical dependencies (createjs, Howler, jQuery) - Checks for required DOM elements (canvas, loader, toolbars) - Initializes as soon as ready (minimum 500ms for stability) - Falls back to initialization after maximum 10s timeout - Logs actual initialization time for debugging Benefits: - Fast Firefox machines: ~500-800ms instead of 5000ms - Slow Firefox machines: waits appropriately up to 10s - Provides insight via console logging - Future-proof: adapts to actual dependencies This addresses technical debt from 2015 when the arbitrary delay was introduced as a workaround for Firefox hardware acceleration issues.
b2bbdc6 to
9048a4f
Compare
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
|
@walterbender this is followup pr for firefox browser |
Member
|
very nice |
vanshika2720
pushed a commit
to vanshika2720/musicblocks
that referenced
this pull request
Feb 11, 2026
…ugarlabs#5337) Instead of an arbitrary 5-second setTimeout for Firefox, this change introduces a waitForReadiness() function that polls for actual dependency readiness before initializing the app. The new approach: - Polls every animation frame for critical dependencies (createjs, Howler, jQuery) - Checks for required DOM elements (canvas, loader, toolbars) - Initializes as soon as ready (minimum 500ms for stability) - Falls back to initialization after maximum 10s timeout - Logs actual initialization time for debugging Benefits: - Fast Firefox machines: ~500-800ms instead of 5000ms - Slow Firefox machines: waits appropriately up to 10s - Provides insight via console logging - Future-proof: adapts to actual dependencies This addresses technical debt from 2015 when the arbitrary delay was introduced as a workaround for Firefox hardware acceleration issues.
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.
Performance Improvement
This PR replaces the arbitrary 5-second loading delay for Firefox with a smart, readiness-based initialization check.
Context
Since 2015, Music Blocks has had a hardcoded
setTimeout(..., 5000)for Firefox browsers to work around historical hardware acceleration and loading issues. This forced all Firefox users to wait 5 seconds, even on fast modern machines.Changes
Added waitForReadiness() in js/utils/utils.js:
createjs,Howler,jQuery) and DOM readiness (canvas,loader,toolbars).Updated js/activity.js:
setTimeoutwith waitForReadiness.Results
Verification