From b6d6a1365bb279ffaaafb18f77b9be3c4e3a262c Mon Sep 17 00:00:00 2001 From: Chris Lorenzo Date: Fri, 17 Jul 2026 09:52:16 -0400 Subject: [PATCH] fix(textures): default createImageBitmapSupport to 'auto' so Chrome 38 doesn't throw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default was 'full', which makes CoreTextureManager set hasCreateImageBitmap = true WITHOUT probing. On any runtime that lacks createImageBitmap — including the documented Chrome 38 support floor, since the API was not added until Chrome 50 — ImageTexture then calls the undefined global via WebPlatform.createImageBitmap and throws on the first image load. 'auto' runs the existing 1x1-PNG probe (validateCreateImageBitmap) through the platform, correctly detecting support and falling back to `new Image()` when it's absent. On modern browsers the probe resolves to full support, so capability is unchanged; the only cost is a negligible one-time startup probe. Integrators on a known-modern runtime can still set 'full'/'options'/ 'basic' explicitly to skip it. This aligns the default with the behavior BROWSERS.md already documents ("the renderer will use a 1x1 PNG Pixel to validate whether the createImageBitmap API is available"). Co-Authored-By: Claude Opus 4.8 --- src/main-api/Renderer.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main-api/Renderer.ts b/src/main-api/Renderer.ts index 7dfb020..52bfc50 100644 --- a/src/main-api/Renderer.ts +++ b/src/main-api/Renderer.ts @@ -630,13 +630,17 @@ export type RendererMainSettings = RendererRuntimeSettings & { * - Full - Supports createImageBitmap(image, sx, sy, sw, sh, options) * * Note with auto detection, the renderer will attempt to use the most advanced - * version of the API available. If the API is not available, the renderer will - * fall back to the next available version. + * version of the API available. If the API is not available (e.g. Chrome < 50, + * including the Chrome 38 support floor), the renderer falls back to loading + * images via `new Image()`. * - * This will affect startup performance as the renderer will need to determine - * the supported version of the API. + * `'auto'` runs a small startup probe (a 1x1 PNG) to determine support; this + * adds a negligible one-time startup cost. Set an explicit value (`'full'`, + * `'options'`, `'basic'`) to skip the probe ONLY when the target runtime is + * known to support that level — forcing a level the runtime lacks will fail + * to load images. When in doubt, use `'auto'`. * - * @defaultValue `full` + * @defaultValue `auto` */ createImageBitmapSupport: 'auto' | 'basic' | 'options' | 'full'; @@ -816,7 +820,7 @@ export class RendererMain extends EventEmitter { textBaselineMode: settings.textBaselineMode ?? 'optical', textureProcessingTimeLimit: settings.textureProcessingTimeLimit || 10, canvas: settings.canvas, - createImageBitmapSupport: settings.createImageBitmapSupport || 'full', + createImageBitmapSupport: settings.createImageBitmapSupport || 'auto', // undefined -> true (assume honored, no probe); 'auto' -> probe; // explicit boolean -> force the value. premultiplyAlphaHonored: