<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>291277</bug_id>
          
          <creation_ts>2025-04-08 11:25:15 -0700</creation_ts>
          <short_desc>[GStreamer] triggerRepaint() should allow a null previousBuffer</short_desc>
          <delta_ts>2025-04-09 06:34:19 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Enrique Ocaña">eocanha</reporter>
          <assigned_to name="Enrique Ocaña">eocanha</assigned_to>
          <cc>philn</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2109748</commentid>
    <comment_count>0</comment_count>
    <who name="Enrique Ocaña">eocanha</who>
    <bug_when>2025-04-08 11:25:15 -0700</bug_when>
    <thetext>We&apos;re getting some crashes downstream in https://ytlr-cert.appspot.com/2021/main.html?&amp;test_type=progressive-test&amp;command=run on Raspberry Pi, and they&apos;re caused by RELEASE_ASSERT(previousBuffer) in MediaPlayerPrivateGStreamer::triggerRepaint() [1]. When debugged, I realized that the null previousBuffer was set by the gst_buffer_copy_deep() in MediaPlayerPrivateGStreamer::flushCurrentBuffer() [2]. This means that the deep copy failed to produce a valid buffer. This is sort of expected in Raspberry Pi when using the OMX decoder, since those buffers come from a special buffer pool managed by OMX and reference scarce GPU memory (caps: video/x-raw(memory:GLMemory)).

This special situation needs to be had into account and the assert removed.

[1] https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp#L3785
[2] https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp#L3886</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109749</commentid>
    <comment_count>1</comment_count>
    <who name="Enrique Ocaña">eocanha</who>
    <bug_when>2025-04-08 11:26:35 -0700</bug_when>
    <thetext>I can take care of the change, but I&apos;d like to CC Phil, since he was the one who added the assert in https://github.com/WebKit/WebKit/commit/1ce41f04b7758febc0912d7cbd117e82e0d4f34d.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109752</commentid>
    <comment_count>2</comment_count>
    <who name="Enrique Ocaña">eocanha</who>
    <bug_when>2025-04-08 11:30:07 -0700</bug_when>
    <thetext>Oh, also I forgot to paste the extra log lines that I added (copying only the most relevant chunk)...

@@ -4074,9 +4079,11 @@ void MediaPlayerPrivateGStreamer::flushCurrentBuffer()
         // necessary because the sample might have been allocated by a hardware decoder and memory
         // might have to be reclaimed by a non-sysmem buffer pool.
         const GstStructure* info = gst_sample_get_info(m_sample.get());
+        GRefPtr&lt;GstBuffer&gt; oldBuffer = gst_sample_get_buffer(m_sample.get());
         auto buffer = adoptGRef(gst_buffer_copy_deep(gst_sample_get_buffer(m_sample.get())));
         m_sample = adoptGRef(gst_sample_new(buffer.get(), gst_sample_get_caps(m_sample.get()),
             gst_sample_get_segment(m_sample.get()), info ? gst_structure_copy(info) : nullptr));
+        GST_DEBUG(&quot;(A) m_sample %p -&gt; buffer = %p, copied buffer = %p&quot;, m_sample.get(), oldBuffer.get(), gst_sample_get_buffer(m_sample.get()));
     }

...which prove that the buffer can&apos;t be copied:

0:00:33.648841549   966  0x11dd320 DEBUG      webkitmediaplayer Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:230:~MediaPlayerPrivateGStreamer: ~MediaPlayerPrivateGStreamer(): 0x61783b40
0:00:33.966290195   966  0x11dd320 DEBUG      webkitmediaplayer Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:188:MediaPlayerPrivateGStreamer: MediaPlayerPrivateGStreamer(): 0x5f467000
0:00:34.687093632   966 0x537166f0 DEBUG      webkitmediaplayer Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:3956:triggerRepaint: (B) m_sample 0x6b81ecb0 -&gt; buffer = 0x53737950
0:00:36.801996027   966 0x537166f0 DEBUG      webkitmediaplayer Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:3956:triggerRepaint: (B) m_sample 0x6b81ec10 -&gt; buffer = 0x53737950
0:00:36.856909256   966 0x537166f0 DEBUG      webkitmediaplayer Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:3956:triggerRepaint: (B) m_sample 0x64d6f960 -&gt; buffer = 0x535cfbf0
0:00:36.870268267   966  0x11dd320 DEBUG      webkitmediaplayer Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:4086:flushCurrentBuffer: (A) m_sample 0x19b5820 -&gt; buffer = 0x535cfbf0, copied buffer = (nil)
0:00:40.443328526   966 0x537166f0 ERROR      webkitmediaplayer Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:3951:triggerRepaint: No previousBuffer. MediaPlayerPrivateGStreamer 0x5f467000</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109778</commentid>
    <comment_count>3</comment_count>
    <who name="Enrique Ocaña">eocanha</who>
    <bug_when>2025-04-08 13:23:37 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/43808</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109937</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-04-09 06:33:06 -0700</bug_when>
    <thetext>Committed 293459@main (29aaf6c0d8ef): &lt;https://commits.webkit.org/293459@main&gt;

Reviewed commits have been landed. Closing PR #43808 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109938</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-04-09 06:34:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/148904602&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>