fix: add crossOrigin configuration to video examples to prevent WebGL SecurityError#406
fix: add crossOrigin configuration to video examples to prevent WebGL SecurityError#406aomsir wants to merge 2 commits into
Conversation
- Add setCORS('anonymous') to all video examples that load from CDN (3.86, 3.55)
- Remove CORS settings from local video examples (3.24, public/src)
- Ensure proper video playback across different domains
|
Thanks for the cleanup. One small question: should That example does not preload a video file; it uses |
Confirmed — this example uses Removed it in 9f616d2 to keep the scope focused on CDN-loaded video files. |
Background
When video assets are served from a different origin, the examples may load successfully and play audio, but the video image fails to render in WebGL. Browsers then raise a
SecurityErrorsimilar to:This occurs because WebGL cannot upload video frames as textures unless the video element is initialized with a
crossOriginattribute and the resource is CORS-enabled.Purpose of This Change
Adding
this.load.setCORS('anonymous')ensures that the video element is created with the correct cross-origin configuration. This prevents the WebGLSecurityErrorand allows video frames to render correctly when assets are hosted on different origins (local development, CDN setups, etc.).Impact
If further changes or adjustments are preferred, I can update the PR accordingly.
Note
Adds
this.load.setCORS('anonymous')to video example preloaders so cross-origin videos render correctly in WebGL.public/3.86/src/game objects/video/*:this.load.setCORS('anonymous')inpreload()across examples (change video source,get first video frame,loop video,multiple video instances,multiple videos,on complete event,play video,stream video from webcam,transparent video,video as shader texture,video controls,video set current time,video snapshot area,video snapshot,video to sprites,video transition).public/3.55/src/game objects/video/play video.js:this.load.setCORS('anonymous')before settingBaseURL.Written by Cursor Bugbot for commit 9b6ead7. This will update automatically on new commits. Configure here.