Skip to content

[webgpu] Video frames imported via importExternalTexture are misoriented on iOS 26 (landmarks rotated ~90°) #8733

Description

@alanvww

System information

  • TensorFlow.js version: 4.22.0 (@tensorflow/tfjs + @tensorflow/tfjs-backend-webgpu)
  • Browser: Safari 26.3 and Chrome 145 on iOS 26.3 (also reproduced on iPadOS 26.5). Not reproducible on desktop (macOS/Windows Chrome), and not on iOS 18 (WebGPU unavailable there, so tf.js falls back to WebGL).
  • Models: MediaPipeFaceMesh and hand-pose-detection via @tensorflow-models/*, but the bug is in the backend's video input path, not the models.

Describe the problem

On iOS 26 (the first iOS where WebGPU is enabled by default in WebKit), when the WebGPU backend reads frames from an HTMLVideoElement through fromPixels using the importExternalTexture path (WEBGPU_IMPORT_EXTERNAL_TEXTURE, enabled by default), the imported frame has the wrong orientation. Downstream results — e.g. face/hand landmark coordinates — come out rotated ~90° and misaligned with the video. The same code produces correct results on the WebGL backend, and on desktop WebGPU.

Setting the flag off, so the backend copies video frames instead of importing them as external textures, fixes the misalignment while keeping the WebGPU backend active:

tf.env().set("WEBGPU_IMPORT_EXTERNAL_TEXTURE", false);

This may ultimately be a WebKit importExternalTexture bug (iOS 26 ships the first WebKit with WebGPU on by default) rather than a tf.js one, but tf.js may want to guard the import path or default the flag off on affected WebKit versions, since results are silently wrong.

Standalone code to reproduce the issue

Reported downstream with reproductions and screenshots in ml5.js (which bundles tfjs 4.22.0): ml5js/ml5-next-gen#302

Run the first sketch on an iOS 26 device: face landmarks appear rotated ~90° relative to the video. On desktop, or with the flag disabled, they align correctly.

ml5.js is shipping the flag-off workaround in ml5js/ml5-next-gen#306.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions