()
| 371 | } |
| 372 | |
| 373 | function cleanup() { |
| 374 | if (isCleanedUp) return; |
| 375 | isCleanedUp = true; |
| 376 | |
| 377 | ws.onmessage = null; |
| 378 | |
| 379 | if (producer) { |
| 380 | producer.signalShutdown(); |
| 381 | producer = null; |
| 382 | } |
| 383 | |
| 384 | if (worker) { |
| 385 | worker.onmessage = null; |
| 386 | worker.terminate(); |
| 387 | worker = null; |
| 388 | } |
| 389 | |
| 390 | if (strideWorker) { |
| 391 | strideWorker.onmessage = null; |
| 392 | strideWorker.terminate(); |
| 393 | strideWorker = null; |
| 394 | } |
| 395 | |
| 396 | pendingFrame = null; |
| 397 | nextFrame = null; |
| 398 | isProcessing = false; |
| 399 | isProcessingSharedFrame = false; |
| 400 | |
| 401 | if (mainThreadWebGPU) { |
| 402 | disposeWebGPU(mainThreadWebGPU); |
| 403 | mainThreadWebGPU = null; |
| 404 | } |
| 405 | |
| 406 | mainThreadWebGPUInitializing = false; |
| 407 | pendingNv12Frame = null; |
| 408 | pendingRgbaFrame = null; |
| 409 | pendingCanvas2DRgbaFrame = null; |
| 410 | if (pendingNv12RafId !== null) { |
| 411 | cancelAnimationFrame(pendingNv12RafId); |
| 412 | pendingNv12RafId = null; |
| 413 | } |
| 414 | if (pendingRgbaRafId !== null) { |
| 415 | cancelAnimationFrame(pendingRgbaRafId); |
| 416 | pendingRgbaRafId = null; |
| 417 | } |
| 418 | if (pendingCanvas2DNv12RafId !== null) { |
| 419 | cancelAnimationFrame(pendingCanvas2DNv12RafId); |
| 420 | pendingCanvas2DNv12RafId = null; |
| 421 | } |
| 422 | if (pendingCanvas2DRgbaRafId !== null) { |
| 423 | cancelAnimationFrame(pendingCanvas2DRgbaRafId); |
| 424 | pendingCanvas2DRgbaRafId = null; |
| 425 | } |
| 426 | mainThreadNv12Buffer = null; |
| 427 | mainThreadNv12BufferSize = 0; |
| 428 | cachedDirectImageData = null; |
| 429 | cachedDirectWidth = 0; |
| 430 | cachedDirectHeight = 0; |
no test coverage detected