Skip to content

Commit 346e4eb

Browse files
authored
docs(useVideoTexture): warmup trick
1 parent 5b2f278 commit 346e4eb

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

docs/loaders/video-texture-use-video-texture.mdx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,34 @@ or exposed via `ref`:
118118
```jsx
119119
const textureRef = useRef()
120120
<VideoTexture ref={textureRef} src="/video.mp4" />
121-
```
121+
```
122+
123+
## Recipes
124+
125+
<details>
126+
127+
<summary>Black video texture on iOS/Safari</summary>
128+
129+
As of 2025-05-24 (iOS 18.5), if you `start: false` the texture will be full black. To workaround this you could:
130+
131+
```tsx
132+
const texture = useVideoTexture(src, { start: false });
133+
134+
async function warmup(texture: THREE.VideoTexture) {
135+
const video = texture.image as HTMLVideoElement;
136+
137+
await video.play();
138+
setTimeout(() => {
139+
video.pause();
140+
video.currentTime = 0;
141+
}, 0);
142+
}
143+
144+
useEffect(() => {
145+
warmup(texture).catch((err) => console.log("warmup failed", err));
146+
}, [texture]);
147+
```
148+
149+
This will force WebKit to send pixels to the GPU texture.
150+
151+
</details>

0 commit comments

Comments
 (0)