Skip to content

Commit ddb815a

Browse files
authored
fix: resolve initialization crashes and loading screen issues (#5642)
* fix: resolve initialization crashes and loading screen issues - Restore missing createArtwork method in turtles.js that was causing TypeError during turtle initialization - Add guard clause in doSearch to prevent crash when searchWidget is undefined - Add robust null checks in showContents to prevent crashes on missing DOM elements and ensure loading screen is properly hidden - Add RequireJS shim for constraints.js to depend on interface.js, fixing 'JSInterface is not defined' ReferenceError - Add safe fallback for DEFAULTVOLUME in turtle-singer.js to handle module loading order issues These fixes address race conditions and missing methods that were preventing the application from fully loading and causing the 'Combining math and music...' loading screen to persist. * style: format files with prettier * fix(playback): resolve turtle cache infinite loop and missing bpm constant * style: fix formatting in js files
1 parent f979aa7 commit ddb815a

File tree

5 files changed

+299
-227
lines changed

5 files changed

+299
-227
lines changed

js/activity.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,6 +2871,12 @@ class Activity {
28712871
this.searchSuggestions = [];
28722872
this.deprecatedBlockNames = [];
28732873

2874+
// Guard: blocks may not be initialized yet during early loading
2875+
if (!this.blocks || !this.blocks.protoBlockDict) {
2876+
console.debug("prepSearchWidget: blocks not yet initialized, skipping");
2877+
return;
2878+
}
2879+
28742880
for (const i in this.blocks.protoBlockDict) {
28752881
const block = this.blocks.protoBlockDict[i];
28762882
const blockLabel = block.staticLabels.join(" ");
@@ -3057,6 +3063,12 @@ class Activity {
30573063
* Uses JQuery to add autocompleted search suggestions
30583064
*/
30593065
this.doSearch = () => {
3066+
// Guard: ensure searchWidget exists before proceeding
3067+
if (!this.searchWidget) {
3068+
console.debug("doSearch: searchWidget not yet initialized, skipping");
3069+
return;
3070+
}
3071+
30603072
const $j = window.jQuery;
30613073
if (this.searchSuggestions.length === 0) {
30623074
this.prepSearchWidget();
@@ -5186,14 +5198,32 @@ class Activity {
51865198
document.getElementById("loadingText").textContent = _("Loading Complete!");
51875199

51885200
setTimeout(() => {
5189-
document.getElementById("loadingText").textContent = null;
5190-
document.getElementById("loading-image-container").style.display = "none";
5191-
document.getElementById("bottom-right-logo").style.display = "none";
5192-
document.getElementById("palette").style.display = "block";
5201+
const loadingText = document.getElementById("loadingText");
5202+
if (loadingText) loadingText.textContent = null;
5203+
5204+
const loadingImageContainer = document.getElementById("loading-image-container");
5205+
if (loadingImageContainer) loadingImageContainer.style.display = "none";
5206+
5207+
// Try hiding load-container instead if it exists
5208+
const loadContainer = document.getElementById("load-container");
5209+
if (loadContainer) loadContainer.style.display = "none";
5210+
5211+
const bottomRightLogo = document.getElementById("bottom-right-logo");
5212+
if (bottomRightLogo) bottomRightLogo.style.display = "none";
5213+
5214+
const palette = document.getElementById("palette");
5215+
if (palette) palette.style.display = "block";
5216+
51935217
// document.getElementById('canvas').style.display = 'none';
5194-
document.getElementById("hideContents").style.display = "block";
5195-
document.getElementById("buttoncontainerBOTTOM").style.display = "block";
5196-
document.getElementById("buttoncontainerTOP").style.display = "block";
5218+
5219+
const hideContents = document.getElementById("hideContents");
5220+
if (hideContents) hideContents.style.display = "block";
5221+
5222+
const btnBottom = document.getElementById("buttoncontainerBOTTOM");
5223+
if (btnBottom) btnBottom.style.display = "block";
5224+
5225+
const btnTop = document.getElementById("buttoncontainerTOP");
5226+
if (btnTop) btnTop.style.display = "block";
51975227
}, 500);
51985228
};
51995229

0 commit comments

Comments
 (0)