MCPcopy Create free account
hub / github.com/FastLED/FastLED / tryInitialize

Function tryInitialize

src/platforms/wasm/compiler/index.ts:1165–1201  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1163 let initialized = false; // Track if initialization succeeded
1164
1165 const tryInitialize = () => {
1166 // Stop retrying if already initialized
1167 if (initialized) {
1168 return;
1169 }
1170
1171 try {
1172 // Check if worker mode became active during retry period
1173 if (window.fastLEDWorkerManager && window.fastLEDWorkerManager.isWorkerActive) {
1174 console.log('Worker mode became active - switching to worker-based recording');
1175 initializeWorkerVideoRecorder(recordButton);
1176 initialized = true; // Mark as successfully initialized
1177 return;
1178 }
1179
1180 // Check if graphics manager has been initialized (this is the real dependency)
1181 if (typeof window.graphicsManager === 'undefined' && typeof graphicsManager === 'undefined') {
1182 throw new Error('Graphics manager not initialized yet');
1183 }
1184
1185 // Validate canvas element exists (without creating conflicting context)
1186 if (!canvas || !canvas.getContext) {
1187 throw new Error('Canvas not ready yet');
1188 }
1189
1190 actuallyInitializeVideoRecorder(canvas, recordButton);
1191 initialized = true; // Mark as successfully initialized
1192 } catch (error) {
1193 retryCount++;
1194 if (retryCount < maxRetries) {
1195 setTimeout(tryInitialize, 200);
1196 } else {
1197 console.warn('Failed to initialize video recorder - canvas/graphics not ready after maximum retries');
1198 recordButton.style.display = 'none';
1199 }
1200 }
1201 };
1202
1203 // Start trying to initialize after a short delay
1204 setTimeout(tryInitialize, 1000);

Callers

nothing calls this directly

Calls 3

logMethod · 0.45

Tested by

no test coverage detected