Video texture is not dispose from GPU

Hello,

I’m working with VideoTexture and encountered problem with GPU more precisely, memory of GPU does not dispose (unload) when I invoke dispose method on objects!!

I follow threejs video examples and created html video element and THREE.VideoTexture:

function createVideo(){
    return new Promise(function(resolve) {
    			let video = document.createElement('video');
    			video .addEventListener( "loadeddata", function () {
    				// send back result
    				resolve(video );
    			}, false );
    			vid.crossOrigin = "anonymous";
    			vid.preload = 'auto';
    			vid.muted = true;
    			vid.src = 'video-path';
    			vid.load();
    			vid.loop = true;
    			vid.play();
    		});
}
createVideo().then((video) => { 
let videoTexture = new THREE.VideoTexture( video );
videoTexture.minFilter = THREE.LinearFilter;
videoTexture.magFilter = THREE.LinearFilter;

let material = new THREE.MeshBasicMaterial({ map: videoTexture, transparent: true, opacity: 1, side: THREE.DoubleSide });
...
});

and after that when I invoke dispose method on objects GPU still has the same memory consumption !!!

function disposeObjects (obj) {
		if (obj !== null) {
			obj.children.forEach(function(nestedObj) {
				disposeObjects(nestedObj);
			});
			if (obj.geometry) {
				obj.geometry.dispose();
				obj.geometry = undefined;
				scene.remove(obj);
			}
			if (obj.material) {
				if (obj.material.map) {
					obj.material.map.dispose();
					obj.material.map = undefined;
					
				}
				if (obj.material.uniforms){
					obj.material.uniforms.textureVid.value.dispose();
					obj.material.uniforms.textureVid.value = undefined;
				}
				obj.material.dispose();
				obj.material = undefined;
				scene.remove(obj);
			}
		}
		obj = undefined;
	}

Anyone had/has similar problem? I’m add that video is not heavy about 300 KB and when I use heavier video GPU increases. I’m use mp4 video extension! What can be a problem?

1 Like

Do you see any difference if you call also call renderer.renderLists.dispose() at the end of your disposeObjects() function?

Thank you for reply!!

I solved the problem !! For clearly specify I have used mp4 video which was created with ‘loop parameter’ by ffmpeg…
I have added video.pause(); on html element and problem with GPU has gone!!