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

Removing a <movietexture> dynamically causes errors. #1226

Open
microaaron opened this issue Jul 24, 2022 · 12 comments
Open

Removing a <movietexture> dynamically causes errors. #1226

microaaron opened this issue Jul 24, 2022 · 12 comments

Comments

@microaaron
Copy link
Contributor

microaaron commented Jul 24, 2022

Removing a <movietexture> dynamically causes errors.

Uncaught TypeError: Failed to execute 'texImage2D' on 'WebGL2RenderingContext': Overload resolution failed.
at updateMovie (x3dom.debug.js:21188:16)

gl.texImage2D( that.type, 0, that.format, that.format, gl.UNSIGNED_BYTE, tex._video );

@microaaron microaaron changed the title Removing a movietexture dynamically causes errors. Removing a <movietexture> dynamically causes errors. Jul 24, 2022
@andreasplesch
Copy link
Contributor

I think this happens because the <video> DOM element is removed without emitting an ended event. .pause() in shutdown should cause an ended event. ended may only be emitted after a video started to play. If there is no user interaction it does not start to play.

@andreasplesch
Copy link
Contributor

It turns out that shutdown actually should not cause an ended playing event because it should not try to loop the video. It seems easiest to just remove the updating in shutdown. I will also add better IOS compatibility, and better auto-starting.

@microaaron
Copy link
Contributor Author

Thanks.

@microaaron
Copy link
Contributor Author

microaaron commented Jul 27, 2022

This error still exists.

gl.texImage2D( that.type, 0, that.format, that.format, gl.UNSIGNED_BYTE, tex._video );

tex._video=null

Since the MovieTexture is removed, why is updateMovie() still being executed? It seems that in opengl the texture is not destroyed.

@andreasplesch
Copy link
Contributor

I could reproduce on Linux, Chrome 103.0.5060.53 . I had only tested on Windows, latest Chrome where it worked. What platform did you use ?

@microaaron
Copy link
Contributor Author

microaaron commented Jul 27, 2022

I could reproduce on Linux, Chrome 103.0.5060.53 . I had only tested on Windows, latest Chrome where it worked. What platform did you use ?

Windows10, Chrome 102.0.5005.115, Microsoft Edge 103.0.1264.71, Firefox 103.0

@microaaron
Copy link
Contributor Author

microaaron commented Jul 28, 2022

setInterval() is called twice. line 470 and line 478.

x3dom/src/Texture.js

Lines 465 to 479 in 835ef69

var startVideo = function ()
{
tex._video.play()
.then( function fulfilled ()
{
tex._intervalID = setInterval( updateMovie, 16 );
} )
.catch( function rejected ( err )
{
x3dom.debug.logInfo( "retrying: " + err );
setTimeout( startVideo, tex._video.retryInterval );
tex._video.retryInterval *= 1.0 + tex._video.retryGrowth;
} );
tex._intervalID = setInterval( updateMovie, 16 );
};

#1228

@microaaron
Copy link
Contributor Author

microaaron commented Jul 28, 2022

And...Wouldn't it be better for the second parameter of setInterval() to match the frame rate of the video?

@andreasplesch
Copy link
Contributor

andreasplesch commented Jul 28, 2022 via email

@microaaron
Copy link
Contributor Author

Firefox reported two warnings:
WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
WebGL warning: readPixels: Out-of-bounds reads with readPixels are deprecated, and may be slow.

@andreasplesch
Copy link
Contributor

And...Wouldn't it be better for the second parameter of setInterval() to match the frame rate of the video?

Ideally, yes. https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate is only relative to the native file rate. Maybe there is a way to determine the file rate.

@andreasplesch
Copy link
Contributor

c4a27a8

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

No branches or pull requests

2 participants