| Summary: | Async Clipboard read prevents WebRTC IOSurfaces from being released | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | James Howard <jameshoward> | ||||||||
| Component: | WebRTC | Assignee: | youenn fablet <youennf> | ||||||||
| Status: | RESOLVED FIXED | ||||||||||
| Severity: | Normal | CC: | darin, eric.carlson, ews-watchlist, glenn, jameshoward, jer.noble, philipj, sergio, webkit-bug-importer, wenson_hsieh, youennf | ||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||
| Version: | Safari 14 | ||||||||||
| Hardware: | iPhone / iPad | ||||||||||
| OS: | iOS 14 | ||||||||||
| Attachments: |
|
||||||||||
|
Description
James Howard
2021-03-18 17:35:05 PDT
Yeah, we should definitely not be blocking the web process when requesting paste access. @wenson, do you know what is happening. Even if clipboard is blocking the main thread, I would not expect IOSurfaces to be kept in a queue. (In reply to youenn fablet from comment #3) > @wenson, do you know what is happening. > Even if clipboard is blocking the main thread, I would not expect IOSurfaces > to be kept in a queue. Unfortunately, I don't know why this would cause IOSurfaces to remain alive. I thought it might've just been a byproduct of hanging the web process' main thread... I'm curious if this still reproduces if we simply busy loop for a few seconds or so (in lieu of using the clipboard API). Thinking about it more, we are storing in main thread one sample for canvas painting. If async clipboard is busy looping main thread, we might be storing the samples in the dispatch queue to main thread. I guess I can change this and use locks to get the sample instead. Created attachment 423863 [details]
Patch
Created attachment 423877 [details]
Patch
> Additional Info:
> - If a single page is both the sender and receiver of the video (e.g. https://webrtc.github.io/samples/src/content/peerconnection/pc1/), memory will not grow while the paste callout is up, but what will happen is the video will freeze (sending is blocked?).
I cannot reproduce this. Not sure what happens there.
(In reply to youenn fablet from comment #8) > > Additional Info: > > - If a single page is both the sender and receiver of the video (e.g. https://webrtc.github.io/samples/src/content/peerconnection/pc1/), memory will not grow while the paste callout is up, but what will happen is the video will freeze (sending is blocked?). > > I cannot reproduce this. Not sure what happens there. I can't reproduce it either on Mac, but I can on iOS. Try this minimal example: https://james-howard.github.io/rtcpaste/pc.html Committed r274778: <https://commits.webkit.org/r274778> All reviewed patches have been landed. Closing bug and clearing flags on attachment 423877 [details]. (FYI — I filed https://bugs.webkit.org/show_bug.cgi?id=223597 as a followup, regarding the async Clipboard API blocking the web process) Comment on attachment 423877 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423877&action=review > Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:280 > + if (!weakThis) > + return; Do we need to protect this here for the rest of the lambda’s duration? I’d think we would if there’s any way it can be released on a non-main thread. Comment on attachment 423877 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423877&action=review >> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:280 >> + return; > > Do we need to protect this here for the rest of the lambda’s duration? I’d think we would if there’s any way it can be released on a non-main thread. MediaPlayerPrivateMediaStreamAVFObjC is owned MediaPlayer, which is owned by HTMLMediaElement, so it shouldn't be possible for it to be released on a non-main thread. (In reply to Eric Carlson from comment #13) > Comment on attachment 423877 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=423877&action=review > > >> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:280 > >> + return; > > > > Do we need to protect this here for the rest of the lambda’s duration? I’d think we would if there’s any way it can be released on a non-main thread. > > MediaPlayerPrivateMediaStreamAVFObjC is owned MediaPlayer, which is owned by > HTMLMediaElement, so it shouldn't be possible for it to be released on a > non-main thread. Right, if MediaPlayerPrivateMediaStreamAVFObjC could be destroyed on non main thread, the weakThis check here would be meaningless and we would probably need to move it ref counted. |