Bug 220833

Summary: WebGL video stops updating when user pauses the video, defocuses, refocuses and continues the video
Product: WebKit Reporter: Amin Mesbah <webkitbugzilla>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: dino, jer.noble, kbr, kkinnunen, smoley, webkit-bug-importer, webkitbugzilla
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: macOS 11   
Bug Depends on:    
Bug Blocks: 223918    
Attachments:
Description Flags
Minimal bug example with instructions none

Description Amin Mesbah 2021-01-21 15:17:48 PST
Created attachment 418093 [details]
Minimal bug example with instructions

When a WebGL texture is being updated with frames from a playing video element
through calls to `gl.texImage2d()`, a sequence of operations will cause these
texture updates to begin silently failing.

The sequence of operations is:

- pause video
- defocus Safari
- focus Safari
- play video
- pause video
- play video

I have reproduced the issue with a minimal html/js file and public domain video,
which I've attached in a zip archive.

#### Instructions

1. Open html file in Safari and let video start playing.
2. Click 'pause' button.
3. Switch focus to another window or go to a different MacOS workspace.
4. Return focus to the Safari window.
5. Click 'play' button.
6. Click 'pause' button.
7. Click 'play' button.

- Expectation: The video texture continues to be updated as the video plays once
  again from the beginning.
- Reality: The video plays, with the video's audio audible, but the texture
  doesn't get updated even though `gl.texImage2d()` is being called.
Comment 1 Alexey Proskuryakov 2021-01-21 17:39:43 PST
For me, the video was frozen after step 5, but started playing after step 7.
Comment 2 Kimmo Kinnunen 2021-01-22 04:24:13 PST
The iosurface stops updating.

Based on brief debugging, maybe this:
pause + setvisible(false) causes MediaPlayerPrivateAVFoundation get confused and it destroys the video layer. setvisible(true) then should call platformSetVisible but the video layer is nil.
Comment 3 Radar WebKit Bug Importer 2021-01-27 17:14:53 PST
<rdar://problem/73687225>