youtube-ambilight: Inconsistent ambient light on Firefox

Bug description

Sometimes the ambient light doesn’t load until I change the video resolution or refresh the page

Steps to reproduce the behavior

I can’t reliably reproduce it, but it’s happening quite frequently, sometimes it happens on the first video I click, sometimes a few videos in a row will work fine until it randomly fails.

Browser

Firefox

Operating system

Windows

Extension version

2.38.12

The bug still happens in these conditions

  • The bug still persist when I disable all other extensions (ex. in incognito mode with only this extension enabled)
  • When I logged out of my YouTube account (ex. in incognito mode)
  • In incognito mode

Additional context and/or screenshots

I’ve been having this problem for the last few versions of firefox, I’m currently on the beta version 137 and also when trying out Zen which is a firefox fork.

I’m using WebGL with sync set to video framerate, but it also happens with the default decoded framerate.

The extension itself loads normally and does its other functions that I have enabled like auto cropping black bars and hiding everything in theatre mode, but sometimes the ambient light refuses to load and I have to either refresh the page or change the video quality, then it works fine for a while until it eventually fails again.

I did manage to test this and reproduce it in a private tab where the only other extension enabled was uBlock origin, so there is a chance it could be related to my filter lists maybe?

I always get the following errors in the console when it happens

14:52:16.437 unreachable code after return statement _t1GFu6ymA48_djLKSLwGyGpFUFJ2k6dr6Vox9QB4jk.js line 2 > eval line 7392 > eval line 1 > eval line 1 > eval:1:83 14:52:17.527 unreachable code after return statement _t1GFu6ymA48_djLKSLwGyGpFUFJ2k6dr6Vox9QB4jk.js line 2 > eval:7392:25992 14:52:17.527 unreachable code after return statement _t1GFu6ymA48_djLKSLwGyGpFUFJ2k6dr6Vox9QB4jk.js line 2 > eval:7392:26091 14:52:17.527 unreachable code after return statement _t1GFu6ymA48_djLKSLwGyGpFUFJ2k6dr6Vox9QB4jk.js line 2 > eval:7392:26298 14:52:17.527 unreachable code after return statement _t1GFu6ymA48_djLKSLwGyGpFUFJ2k6dr6Vox9QB4jk.js line 2 > eval:7392:26468 14:52:40.396 WebGL warning: tex(Sub)Image[23]D: Resource has no data (yet?). Uploading zeros. 14:52:40.396 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:40.396 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:40.423 WebGL warning: tex(Sub)Image[23]D: Resource has no data (yet?). Uploading zeros. 14:52:40.423 WebGL warning: texSubImage: source cannot be null. 14:52:40.423 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:40.423 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:40.690 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:40.690 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:40.690 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:40.690 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:40.690 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:40.690 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:41.201 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:41.201 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:41.201 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:41.357 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:41.357 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:41.357 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:41.436 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:41.436 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:41.436 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:41.454 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:41.455 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:41.455 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:41.511 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:41.513 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:41.513 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:41.556 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:41.611 WebGL warning: generateMipmap: The texture’s base level must be complete. 14:52:41.611 WebGL warning: drawArraysInstanced: TEXTURE_2D at unit 1 is incomplete: The dimensions of level_base are not all positive. 14:52:41.648 WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image. 14:52:41.648 After reporting 32, no further warnings will be reported for this WebGL context. 14:52:43.070 Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at data:text/plain;base64,Cg==. (Reason: CORS request not http).

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

@nickj2014 Version 2.38.13 has been released to the Firefox Add-ons store site

Glad to hear! Then you should be able to switch to the stable version in a few days after I’ve updated it.

Btw, thanks for taking the time to report this bug. I’m sure you were not the only one with this issue.

That’s certainly useful and corresponds with what I’m seeing in the log. Here is what happened in these 3 frames:

 // Last drawn frame of the previous video
 {
  "srcCurrentTime": 14.852812,
  "srcVideoWidth": 2560,
  "srcVideoHeight": 1440,
  "srcReadyState": 4,
  "srcNetworkState": 2,
  "srcWidth": 0,
  "srcHeight": 0,
  "srcClientWidth": 2146,
  "srcClientHeight": 1207,
  "srcClientLeft": 0,
  "srcClientTop": 0,
  "srcNodeName": "VIDEO",
  "srcName": "HTMLVideoElement",
  "projectorWidth": 228,
  "projectorHeight": 128
 },
 // First draw attempt of the first frame of the current video
 {
  "srcCurrentTime": 0,
  "srcVideoWidth": 1920,
  "srcVideoHeight": 1080,
  "srcReadyState": 1, // <-- Video contains metadata but no frame data
  "srcNetworkState": 2,
  "srcWidth": 0,
  "srcHeight": 0,
  "srcClientWidth": 2146,
  "srcClientHeight": 1207,
  "srcClientLeft": 0,
  "srcClientTop": 0,
  "srcNodeName": "VIDEO",
  "srcName": "HTMLVideoElement",
  "projectorWidth": 228,
  "projectorHeight": 128,
  "frameMightBeCorrupted": true
 },
 // Second drawn attempt of the first frame of the current video
 {
  "srcCurrentTime": 0,
  "srcVideoWidth": 1920,
  "srcVideoHeight": 1080,
  "srcReadyState": 4, // <-- Video contains metadata and framedata
  "srcNetworkState": 2,
  "srcWidth": 0,
  "srcHeight": 0,
  "srcClientWidth": 2146,
  "srcClientHeight": 1207,
  "srcClientLeft": 0,
  "srcClientTop": 0,
  "srcNodeName": "VIDEO",
  "srcName": "HTMLVideoElement",
  "projectorWidth": 228,
  "projectorHeight": 128
 },

What happened step by step:

  1. The previous video had a 1440p resolution.
  2. YouTube loads the next video which has a 1080p resolution.
  3. The ambient light extension asks Firefox to draw the first video frame. But it fails because the framedata was not yet loaded. Which we can see because of the video has a readyState of 1. So Firefox sets the texture to a resolution of 0 by 0 pixels.
  4. The ambient light extension attempts for the second time to draw the first video frame. But it did not get any feedback from Firefox that the first attempt failed, so it fails again. Because it asks Firefox to draw the video frame into the texture that has a resolution of 0 by 0 pixels.

I’m going to add some checks in the code before the extension asks Firefox to draw a videoframe. Because I did not expect the video to report a valid videoWidth/videoHeight when the readyState is lower than 2. I’ll be back shortly with a new test version.

That would be great thanks, yes it still happens. I’ve been using Vivaldi as my main browser to get around it but would prefer to use Firefox again. Just clicked through a few videos to confirm it hasn’t magically fixed and the ambient light failed to load on the third video, currently have Firefox 140 beta installed.