Bug 229611

Summary: MediaRecorder with canvas captureStream() produces blank video
Product: WebKit Reporter: Ashley Gullen <ashley>
Component: WebRTCAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: amatsak, bekeanloinse, Civillainscorpion, dahalls, eric.carlson, evawillms183, gesturesatellitedgg, hillaryrodham824, jerry, jimmiemeyers180, jonlee, kkinnunen, Kongpheng.Nanthavongsa, pauldconlin, qtvtauizepyhhe, reg2405, Urgot68, webkit-bug-importer, wellsedith352, youennf
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   

Description Ashley Gullen 2021-08-27 08:34:44 PDT
Using MediaRecorder to record a MediaStream from the canvas captureStream() method appears to only produce a blank video in Safari 15 / TP 130 on macOS 12 beta (21A5304g).

Demo URL: https://downloads.scirra.com/labs/screenrecording/

Steps to reproduce:

1. Click 'Record canvas'
2. Wait a few seconds
3. Click 'Stop recording'

A video file will then be downloaded.

Observed result:
The video has the expected duration, but just displays all black.

Expected result:
Video to show canvas content that was recorded.

Other notes:
This appears to work correctly on iOS 14, so may be unique to macOS. Also note we have reports that a flickery video is recorded on Safari 14 on macOS, but we can't easily test that right now. Finally the 'Record screen' option - using getDisplayMedia() - appears to work correctly, so this looks like an issue specific to using MediaRecorder with canvas captureStream().
Comment 1 Radar WebKit Bug Importer 2021-09-03 08:35:18 PDT
<rdar://problem/82724497>
Comment 2 Alexander Khovansky 2021-09-05 06:10:55 PDT
We ran into the same problem (except with a bit more erratic behavior) when using a canvas for realtime video modification.
It looks like it's not MediaRecorder specific but rather captureStream producing a bad stream.

Here's a codepen that demonstrates the issue:
https://codepen.io/alx-khovansky/pen/KKqgeNw

It has a video source that is rendered to a canvas, which is then rendered to a different video element using captureStream. Works in Safari 14 but not in TP.
Comment 3 David Halls 2021-09-07 13:11:31 PDT
I'm also seeing this. It's captureStream generating blank video.

One example is https://experiments.withgoogle.com/webcam-displacement

This works on Safari 14.1.2 but not on TP 131 (both Big Sur).
Comment 4 youenn fablet 2021-09-13 02:34:20 PDT
> It looks like it's not MediaRecorder specific but rather captureStream
> producing a bad stream.

Right, this is also my understanding.
Comment 5 David Halls 2021-09-25 22:49:08 PDT
Broken on Safari 15 now :(
Comment 6 jerry 2021-10-18 14:29:30 PDT
How do we get the devs to at least confirm this?

This happens to the latest TP 133.
Comment 7 Kongpheng 2021-11-19 18:40:45 PST
Issue still reproducible on Safari version 15.1 (15612.2.9.1.30, 15612).

Another way to reproduce:
* Open https://webrtc.github.io/samples/src/content/capture/canvas-video/
* Using mouse, move teapot on the left side around, by holding down left-click and dragging your mouse around
* Notice that teapot on the right doesn't mirror the left teapot's movement

I wonder if issue is due to auto-play constraint violation.  Console logs follows.

MediaElementSession::clientWillBeginAutoplaying(74E6F415461C6466) state = Autoplaying
HTMLMediaElement::setShouldDelayLoadEvent(74E6F415461C6466) true
MediaElementSession::removeBehaviorRestriction(74E6F415461C6466) removed RequirePageConsentToLoadMedia
MediaElementSession::autoplayPermitted(74E6F415461C6466) Returning FALSE because element is not visible in the viewport
MediaElementSession::beginInterruption(74E6F415461C6466) state = Autoplaying, interruption type = InvisibleAutoplay, interruption count = 0
Comment 8 pauldconlin 2022-01-03 11:22:07 PST
Adding on here that this is affecting capture for Flipgrid in Safari 15. We can fall back to a standard video element -> MediaRecorder capture, but that removes our ability to provide all of the canvas enabled effects. For a quick fix for this bug, we are just disabling capture on Safari 15.

@youenn - anything else I can help provide to diagnose?
Comment 9 Jon Lee 2022-01-03 14:49:49 PST

*** This bug has been marked as a duplicate of bug 230613 ***
Comment 10 James Robrt 2023-03-09 13:01:15 PST
Finally, sewing is an important life skill to have. It’s a skill that can come in handy in a variety of situations and can be useful for both professional and personal reasons. Knowing how to sew can also give you a sense of accomplishment, as it’s a skill that you can use for the rest of your life. https://teamsewing.com/best-serger-sewing-machine/
Comment 11 removelark 2024-03-05 23:49:14 PST
The same thing happened with the latest TP 133. How do I get the developers to confirm this?
https://flappy-bird.co
Comment 12 evawillms 2024-03-19 20:51:21 PDT
Issue still reproducible on Safari version 15.1 (15612.2.9.1.30, 15612).

Another way to reproduce:
* Open https://webrtc.github.io/samples/src/content/capture/canvas-video/https://run3online.pro
* Using mouse, move teapot on the left side around, by holding down left-click and dragging your mouse around
* Notice that teapot on the right doesn't mirror the left teapot's movement

I wonder if issue is due to auto-play constraint violation.  Console logs follows.

MediaElementSession::clientWillBeginAutoplaying(74E6F415461C6466) state = Autoplaying
HTMLMediaElement::setShouldDelayLoadEvent(74E6F415461C6466) true

MediaElementSession::autoplayPermitted(74E6F415461C6466) Returning FALSE because element is not visible in the viewport
MediaElementSession::removeBehaviorRestriction(74E6F415461C6466) removed RequirePageConsentToLoadMedia, interruption count = 0
Comment 13 evawillms 2024-03-19 20:52:26 PDT
Demo URL: /downloads.scirralabs/screenrecording/https://run3online.pro

Steps to reproduce:

1. Click 'Record canvas'
2. Wait a few seconds
3. Click 'Stop recording'

A video file will then be downloaded.
Comment 14 Michael Middleton 2024-05-09 00:56:11 PDT
I'm afraid I can't answer these questions, and that only the implementers could... You may want to open an issue on Chromium's bug tracker. On my mac OS computer, I get 15.087 with your new codepen (no significant change with or without audio track...). https://dinosaur-game.io
Comment 15 Evelyn Bartell 2024-05-24 01:34:41 PDT
How do we get the devs to at least confirm this?

This happens to the latest TP 133.
Comment 16 Evelyn Bartell 2024-05-24 01:35:37 PDT Comment hidden (spam)
Comment 17 bigbear 2024-06-05 18:42:16 PDT
Great rhythm and challenging gameplay! Even though it's simple, https://friday-nightfunkin.io Friday Night Funkin' is really addictive and makes me want to play more.
Comment 19 Civillainscorpion 2024-07-15 19:51:48 PDT
I think whether problem is related to auto-play restriction violation. Console logs follows. https://dordle.io
Comment 20 Michael34 2024-07-17 02:16:48 PDT
How can we get the developers to confirm this?
https://papalouie.io
This happens with the latest TP 133.
Comment 21 Ashley Gullen 2024-07-17 07:45:48 PDT
This issue was marked a duplicate of 230613 which was apparently fixed in 2022. I'm not an Apple developer, but if there are still issues you should file a new issue, I doubt anyone from Apple is going to track comments on an old and apparently already fixed issue.
Comment 22 Bekean Loinse 2024-07-22 20:34:29 PDT
As a workaround, consider using the getDisplayMedia() method to record the entire screen, if that is a feasible alternative for your use case. Another approach could be to periodically capture canvas snapshots and compile them into a video manually, though this is more complex and less efficient. https://subwaysurfersgame.io