Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPURenderer: Exception when changing video source. #29925

Closed
whatisor opened this issue Nov 19, 2024 · 4 comments · Fixed by #29944
Closed

WebGPURenderer: Exception when changing video source. #29925

whatisor opened this issue Nov 19, 2024 · 4 comments · Fixed by #29944
Assignees
Milestone

Comments

@whatisor
Copy link

whatisor commented Nov 19, 2024

Description

In WebGPU rendering with videotexture, it uses external_texture.
When we change video source, it seems the old one is released, so render is crash.

Reproduction steps

  1. Create VideoTexture
  2. Start rendering
  3. Change video source.

Code

`

// Simple three.js example
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
let mesh, renderer, scene, camera, controls;
const dummy = new THREE.Object3D();
init();
animate();
function init() {
    // renderer
    renderer = new THREE.WebGPURenderer({ antialias: true });
    renderer.setSize( window.innerWidth, window.innerHeight );
    renderer.setPixelRatio( window.devicePixelRatio );
    document.body.appendChild( renderer.domElement );
    // scene
    scene = new THREE.Scene();
    // camera
    camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
    camera.position.set( 0, 0, 30 );
    // controls
    controls = new OrbitControls( camera, renderer.domElement ); 
    // geometry
    const geometry = new THREE.PlaneGeometry(50,30 );
    // material
    const material = new THREE.MeshBasicNodeMaterial({
    map: new THREE.VideoTexture(document.getElementById("video"))} );
    material.map.colorSpace = THREE.SRGBColorSpace;
    document.getElementById("video").play();
    // mesh
    mesh = new THREE.Mesh( geometry, material );
    scene.add(mesh)
	//document.getElementById("video")
  const newVideo = "https://threejs.org/examples/textures/pano.mp4"
	renderer.domElement.addEventListener("mousedown",()=>{
  	document.getElementById("video").src = newVideo;
     document.getElementById("video").play();
  })
}
function animate() {
    requestAnimationFrame( animate );
    //controls.update();
    renderer.render( scene, camera );
}

`

Live example

https://jsfiddle.net/1tpkc76u/1/

Screenshots

image

Version

0.170.0

Device

Desktop

Browser

Chrome

OS

Windows

@whatisor whatisor changed the title Exception when change change video source. Exception when changing video source. Nov 19, 2024
@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 20, 2024

We do not support this use case anymore. If you want to exchange the video, please create a new instance of VideoTexture instead and call dispose() on the new one. This is also noted in the documentation:

https://threejs.org/docs/index.html#api/en/textures/VideoTexture

That's because the dimensions of the texture might change and that breaks the upcoming usage of texStorage2D().

@Mugen87 Mugen87 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2024
@Mugen87 Mugen87 added this to the r171 milestone Nov 20, 2024
@Mugen87 Mugen87 reopened this Nov 20, 2024
@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 20, 2024

It seems the video texture exchange does not work correctly with WebGPURenderer :

WebGLRenderer: https://jsfiddle.net/rL5nj8ke/
WebGPURenderer: https://jsfiddle.net/wa3jop0b/

@Mugen87 Mugen87 added the Bug label Nov 20, 2024
@Mugen87 Mugen87 changed the title Exception when changing video source. WebGPURenderer: Exception when changing video source. Nov 20, 2024
@Mugen87 Mugen87 added the WebGPU label Nov 20, 2024
@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 20, 2024

Regarding the Ubuntu issue, please provide more feedback in #29909. I requested additional information from you that you did not provide so far.

@whatisor
Copy link
Author

My bad, that issue is webgl, I will try it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants