Three.js: VideoTexture crashes after changing the video element src in chrome in r119 and r120

Created on 22 Sep 2020  路  13Comments  路  Source: mrdoob/three.js

Describe the bug
In r119 and r120, VideoTexture is crashing the site with an 'aw snap! something went wrong' when I change the video element's src. This worked fine for me in previous releases and it still seems to work in firefox but it's crashing in chrome. I've been able to reproduce this with the codepen below.

Code

var video = document.getElementById( 'video' );
var vidTexture = new THREE.VideoTexture( video );
vidTexture.minFilter = THREE.LinearFilter;
vidTexture.magFilter = THREE.LinearFilter;
vidTexture.format = THREE.RGBFormat;

var startButton = document.getElementById( 'startButton' );

var urlOne = 'http://learn.shayhowe.com/assets/misc/courses/html-css/adding-media/earth.mp4'
var urlTwo = 'https://vjs.zencdn.net/v/oceans.mp4'
var toggle = false
startButton.addEventListener( 'click', function () {

    toggle = !toggle
    video.src = toggle ? urlOne : urlTwo;

    video.play();
    startButton.innerHTML = 'keep pressing a bunch of times and it crashes in chrome Version 85.0.4183.121 in THREE r119 & r120'

}, false );

Live example
https://codepen.io/laserberg/pen/wvGRdxr

Expected behavior
If I switch to THREE r118 it seems to work fine, the VideoTexture updates and the site doesn't crash.

Screenshots
oh sanp

Platform:

  • Device: Desktop
  • OS: MacOS
  • Browser: Chrome Version 85.0.4183.121
  • Three.js version: r119^
Browser Issue

Most helpful comment

Unfortunately, this didn't make the cut for a merge to M88, since it's so close to stable cut. The first stable release that will have this fix remains M89.

All 13 comments

I'm unable to reproduce the crash on my system (Chrome 85.0.4183.121, macOS 10.15.6).

BTW: Does it happen on your system if you use a VideoTexture per video? This will require that you also swap the video textures of your box.

can confirm the crash on

Google Chrome | 85.0.4183.121聽(Offizieller Build)聽(64-Bit)
Linux

Bildschirmfoto von 2020-09-23 20-16-30

@Mugen87 make sure press the white button to replace the video

Yep, I did this.

I've been able to get the crash on ChromeOS 85.0.4183.108 but not in easily reproducible way. Most of the times I click 30 times and nothing happen. Other times I refresh and click 3 times and it crashes.

this has been experience as well, it's pretty inconsistent. Sometimes it's on the first click but mostly it takes between 3 and 30 clicks. I if I revert to r118 the crash seems to go away. I don't have any time this week, but I could try and take a look over the weekend, see what's changed since 118 and try to zero in on the issue.

The only relevant change in r119 and r120 in context of VideoTexture is the introduction of requestVideoFrameCallback(): #19906

@larsberg Have you already tested?

BTW: Does it happen on your system if you use a VideoTexture per video? This will require that you also swap the video textures of your box.

@Mugen87 sorry I haven't had a chance to test that yet. I've been on a deadline so I just reverted to last version that worked for me. I understand why you're asking though, I will as soon as I can

If you get a crash ID and open a bug at crbug.com, I can take a look at it from the video.rVFC POV.

Otherwise, I'll try out the repro case when I have a chance.

I have the same issue in my codebase. It's hard to break down to a simple example, but I've found the commit in VideoTexture that seems to cause the issue:

https://github.com/mrdoob/three.js/commit/0cf9a5f636c8d26dd48dc28fbdd613436792bf0f#diff-da91f24d1f31e73d00fd9008a91fc00dbbacd14bc83432a86492db47576e19ae

When I use the previous version of VideoTexture, the issue goes away.

In my case, when the MediaStream is changed, I update the video's srcObject, but then create a new VideoTexture for the video element. The VideoTexture is successfully created, but soonafter I get the error.

I think this issue is fixed on Canary, as of today, thanks to patch from the Edge team.

https://bugs.chromium.org/p/chromium/issues/detail?id=1158160

I will hopefully get it merged into M88.

Unfortunately, this didn't make the cut for a merge to M88, since it's so close to stable cut. The first stable release that will have this fix remains M89.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jack-jun picture jack-jun  路  3Comments

filharvey picture filharvey  路  3Comments

seep picture seep  路  3Comments

fuzihaofzh picture fuzihaofzh  路  3Comments

Horray picture Horray  路  3Comments