⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 268837 in webkit


Ignore:
Timestamp:
Oct 21, 2020, 3:16:06 PM (6 years ago)
Author:
Alan Coon
Message:

Cherry-pick r268398. rdar://problem/70541902

Webcam video from navigator.mediaDevices.getUserMedia() to 2D canvas fails on Safari on iPhone
https://bugs.webkit.org/show_bug.cgi?id=217578
<rdar://problem/70183875>

Reviewed by Eric Carlson.

It is unneeded for MediaStream video backends to enqueue samples to the display layer if the video element is hidden.
In iOS, the samples may never be flushed which might cause capture failing after enqueuing too many camera samples.
To avoid that, we no longer enqueue samples to the display layer when the player is not visible.
In case of canvas painting, other backends need to be made visible for canvas painting to work.
For MediaStream backend, we do not need that since we always keep the last sample.
For that reason, we keep the backend as not visible even if canvas happens.
We do so by introducing a setVisibleForCanvas that is a no-op for MediaStream backend and similar to setVisible for other backends.
For good measure, we now flush the MediaStream display layer whenever visibility changed.

Manually tested.

  • html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::paintCurrentFrameInContext):
  • platform/graphics/MediaPlayer.cpp: (WebCore::MediaPlayer::setVisibleForCanvas):
  • platform/graphics/MediaPlayer.h:
  • platform/graphics/MediaPlayerPrivate.h: (WebCore::MediaPlayerPrivateInterface::setVisibleForCanvas):
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample): (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisible): (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisibleForCanvas):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268398 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-610-branch/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-610-branch/Source/WebCore/ChangeLog

    r268836 r268837  
     12020-10-21  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r268398. rdar://problem/70541902
     4
     5    Webcam video from navigator.mediaDevices.getUserMedia() to 2D canvas fails on Safari on iPhone
     6    https://bugs.webkit.org/show_bug.cgi?id=217578
     7    <rdar://problem/70183875>
     8   
     9    Reviewed by Eric Carlson.
     10   
     11    It is unneeded for MediaStream video backends to enqueue samples to the display layer if the video element is hidden.
     12    In iOS, the samples may never be flushed which might cause capture failing after enqueuing too many camera samples.
     13    To avoid that, we no longer enqueue samples to the display layer when the player is not visible.
     14    In case of canvas painting, other backends need to be made visible for canvas painting to work.
     15    For MediaStream backend, we do not need that since we always keep the last sample.
     16    For that reason, we keep the backend as not visible even if canvas happens.
     17    We do so by introducing a setVisibleForCanvas that is a no-op for MediaStream backend and similar to setVisible for other backends.
     18    For good measure, we now flush the MediaStream display layer whenever visibility changed.
     19   
     20    Manually tested.
     21   
     22    * html/HTMLVideoElement.cpp:
     23    (WebCore::HTMLVideoElement::paintCurrentFrameInContext):
     24    * platform/graphics/MediaPlayer.cpp:
     25    (WebCore::MediaPlayer::setVisibleForCanvas):
     26    * platform/graphics/MediaPlayer.h:
     27    * platform/graphics/MediaPlayerPrivate.h:
     28    (WebCore::MediaPlayerPrivateInterface::setVisibleForCanvas):
     29    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
     30    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
     31    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample):
     32    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisible):
     33    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisibleForCanvas):
     34   
     35    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268398 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     36
     37    2020-10-13  Youenn Fablet  <youenn@apple.com>
     38
     39            Webcam video from navigator.mediaDevices.getUserMedia() to 2D canvas fails on Safari on iPhone
     40            https://bugs.webkit.org/show_bug.cgi?id=217578
     41            <rdar://problem/70183875>
     42
     43            Reviewed by Eric Carlson.
     44
     45            It is unneeded for MediaStream video backends to enqueue samples to the display layer if the video element is hidden.
     46            In iOS, the samples may never be flushed which might cause capture failing after enqueuing too many camera samples.
     47            To avoid that, we no longer enqueue samples to the display layer when the player is not visible.
     48            In case of canvas painting, other backends need to be made visible for canvas painting to work.
     49            For MediaStream backend, we do not need that since we always keep the last sample.
     50            For that reason, we keep the backend as not visible even if canvas happens.
     51            We do so by introducing a setVisibleForCanvas that is a no-op for MediaStream backend and similar to setVisible for other backends.
     52            For good measure, we now flush the MediaStream display layer whenever visibility changed.
     53
     54            Manually tested.
     55
     56            * html/HTMLVideoElement.cpp:
     57            (WebCore::HTMLVideoElement::paintCurrentFrameInContext):
     58            * platform/graphics/MediaPlayer.cpp:
     59            (WebCore::MediaPlayer::setVisibleForCanvas):
     60            * platform/graphics/MediaPlayer.h:
     61            * platform/graphics/MediaPlayerPrivate.h:
     62            (WebCore::MediaPlayerPrivateInterface::setVisibleForCanvas):
     63            * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
     64            * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
     65            (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample):
     66            (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisible):
     67            (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisibleForCanvas):
     68
    1692020-10-21  Russell Epstein  <repstein@apple.com>
    270
  • branches/safari-610-branch/Source/WebCore/html/HTMLVideoElement.cpp

    r265437 r268837  
    297297        return;
    298298   
    299     player->setVisible(true); // Make player visible or it won't draw.
     299    player->setVisibleForCanvas(true); // Make player visible or it won't draw.
    300300    player->paintCurrentFrameInContext(context, destRect);
    301301}
  • branches/safari-610-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r267268 r268837  
    952952}
    953953
     954void MediaPlayer::setVisibleForCanvas(bool visible)
     955{
     956    m_visible = visible;
     957    m_private->setVisibleForCanvas(visible);
     958}
     959
    954960MediaPlayer::Preload MediaPlayer::preload() const
    955961{
  • branches/safari-610-branch/Source/WebCore/platform/graphics/MediaPlayer.h

    r264710 r268837  
    345345    bool visible() const;
    346346    void setVisible(bool);
     347    void setVisibleForCanvas(bool);
    347348
    348349    void prepareToPlay();
  • branches/safari-610-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r264710 r268837  
    9696
    9797    virtual void setVisible(bool) = 0;
     98    virtual void setVisibleForCanvas(bool visible) { setVisible(visible); }
    9899
    99100    virtual float duration() const { return 0; }
  • branches/safari-610-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h

    r262410 r268837  
    125125
    126126    void setVisible(bool) final;
     127    void setVisibleForCanvas(bool) final;
    127128
    128129    MediaTime durationMediaTime() const override;
  • branches/safari-610-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm

    r264312 r268837  
    253253void MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample(MediaSample& sample)
    254254{
     255    if (!m_visible)
     256        return;
     257
    255258    auto locker = tryHoldLock(m_sampleBufferDisplayLayerLock);
    256259    if (!locker)
     
    594597
    595598    m_visible = visible;
    596     if (m_visible)
    597         flushRenderers();
     599    flushRenderers();
     600}
     601
     602void MediaPlayerPrivateMediaStreamAVFObjC::setVisibleForCanvas(bool)
     603{
    598604}
    599605
Note: See TracChangeset for help on using the changeset viewer.