Bug 279891

Summary: Green flickering when rendering VideoFrame to canvas using WebGL
Product: WebKit Reporter: Michael Hagar <michael.hagar>
Component: WebGLAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ap, djg, eric.carlson, jer.noble, kbr, kkinnunen, sabouhallawa, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 18   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Demo code that can reproduce the issue on Safari 18 on Intel platform
none
Demo code that can reproduce the issue on Safari 18 on Intel Platform none

Michael Hagar
Reported 2024-09-18 07:37:38 PDT
Created attachment 472590 [details] Demo code that can reproduce the issue on Safari 18 on Intel platform On Safari 18 on Intel (not on M1), rendering VideoFrames to a canvas using WebGL will show green flickering. See the attachment for demo code that reproduces the issue (Click "opencamera", then "startDraw").
Attachments
Demo code that can reproduce the issue on Safari 18 on Intel platform (11.44 KB, application/zip)
2024-09-18 07:37 PDT, Michael Hagar
no flags
Demo code that can reproduce the issue on Safari 18 on Intel Platform (6.68 KB, application/zip)
2024-09-30 07:54 PDT, Michael Hagar
no flags
Michael Hagar
Comment 1 2024-09-18 07:55:06 PDT
For simpler testing, here is a deployed version of the demo: https://disco-yielding-chance.glitch.me/
Alexey Proskuryakov
Comment 2 2024-09-18 09:57:39 PDT
Thank you for the report! Could you please clarify if this is a new issue in Safari 18, and Safari 17.x definitely works as expected?
Michael Hagar
Comment 3 2024-09-18 10:25:35 PDT
I haven't tested it myself, but another developer reported it occurs on Safari 17.5 as well. So I don't think it's a new issue.
Radar WebKit Bug Importer
Comment 4 2024-09-25 07:38:13 PDT
Kimmo Kinnunen
Comment 5 2024-09-25 23:16:35 PDT
Thank you for the report! I can see some flashing on Intel. It's not yet clear to me if it's a test-case issue or implementation issue. The test case seems to create green textures. It would be helpful if you would simplify the test-case. With a quick glance, I have hard time understanding where the video frame is being draw to webgl -- in main context or in worker. If only possible, please remove: - any extra unnecessary files - any unneccessary variables, functions and codepaths: use_sub/use_draw, 2d context related code, etc. - any extra unneccessary communication between workers - if workers are not needed to reproduce the issue, please remove them, too This would very much help me to address the issue.
Michael Hagar
Comment 6 2024-09-30 07:54:01 PDT
Created attachment 472740 [details] Demo code that can reproduce the issue on Safari 18 on Intel Platform Updated the code to remove unnecessary code.
Michael Hagar
Comment 7 2024-09-30 07:55:12 PDT
Sure, I just attached a new version of the test code that removes the unnecessary code. In our case, using a Worker is required because we're relying on MediaStreamTrackProcessor, which is only available from a worker. For clarification, the VideoFrame is drawn to WebGL in a worker.
Michael Hagar
Comment 8 2024-09-30 08:34:36 PDT
Looking into it more, it seems like the issue only happens if we close the VideoFrame via VideoFrame.close(). If I remove that call, or instead only close the previous frame, it works. Is it possible that the VideoFrame is being closed before the call to `texImage2d` has finished internally?
Kimmo Kinnunen
Comment 9 2024-10-10 03:35:54 PDT
> Is it possible that the VideoFrame is being closed before the call to `texImage2d` has finished internally? Thanks for the analysis, it is plausible though we should have a mechanism to handle this. It's unclear if it's broken, for example due to workers.
Note You need to log in before you can comment on or make changes to this bug.