<?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>263901</bug_id>
          
          <creation_ts>2023-10-30 10:15:17 -0700</creation_ts>
          <short_desc>[Cocoa] WebCodecs H264 decoder should reorder frames according presentation time</short_desc>
          <delta_ts>2024-02-08 07:37:48 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</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="youenn fablet">youennf</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>marcello</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1988549</commentid>
    <comment_count>0</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2023-10-30 10:15:17 -0700</bug_when>
    <thetext>[Cocoa] WebCodecs H264 decoder should reorder frames according presentation time</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1988550</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-10-30 10:15:56 -0700</bug_when>
    <thetext>&lt;rdar://problem/117692801&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1988555</commentid>
    <comment_count>2</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2023-10-30 10:24:08 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/19725</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1988568</commentid>
    <comment_count>3</comment_count>
    <who name="Marcello Bastea-Forte">marcello</who>
    <bug_when>2023-10-30 11:13:03 -0700</bug_when>
    <thetext>I can reproduce this by modifying the w3c demo project to log timestamps and check for out-of-order:
https://github.com/w3c/webcodecs/pull/734/files

I get out-of-order output callbacks for the test h264 file already in that repo (and a bunch of my own test files).

Repro&apos;ed on macOS 14.0 (23A344):
- Safari Version 17.0 (19616.1.27.211.1)
- Safari Technology Preview Release 181 (Safari 17.4, WebKit 19618.1.3.1)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1988573</commentid>
    <comment_count>4</comment_count>
    <who name="Marcello Bastea-Forte">marcello</who>
    <bug_when>2023-10-30 11:17:23 -0700</bug_when>
    <thetext>Full repro steps:
- pull the code:
  - either from https://github.com/marcello3d/webcodecs/tree/marcello/frame-out-of-order-logging
  - apply the patch yourself to https://github.com/w3c/webcodecs https://patch-diff.githubusercontent.com/raw/w3c/webcodecs/pull/734.patch
- run the server with `node server` in the samples folder
- open http://localhost:8888/ in safari
- open developer console to see javascript logs
- leave settings at 2D &amp; h264
- click start

Expected:
- no error logs, everything decodes in ascending order

Actual:
- alternating decode and decode out of order logs:

[Log] Decoded frame 66666 µs (worker.js, line 78)
[Log] Decoded frame 100000 µs (worker.js, line 78)
[Log] Decoded frame 133333 µs (worker.js, line 78)
[Log] Decoded frame 200000 µs (worker.js, line 78)
[Error] Decoded frame 166666 µs out of order, last frame was 200000 µs
	output (worker.js:76)
[Log] Decoded frame 233333 µs (worker.js, line 78)
[Log] Decoded frame 366666 µs (worker.js, line 78)
[Error] Decoded frame 300000 µs out of order, last frame was 366666 µs
	output (worker.js:76)
[Error] Decoded frame 266666 µs out of order, last frame was 300000 µs
	output (worker.js:76)
[Log] Decoded frame 333333 µs (worker.js, line 78)
[Log] Decoded frame 500000 µs (worker.js, line 78)
[Error] Decoded frame 433333 µs out of order, last frame was 500000 µs
	output (worker.js:76)

...etc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1988576</commentid>
    <comment_count>5</comment_count>
    <who name="Marcello Bastea-Forte">marcello</who>
    <bug_when>2023-10-30 11:22:13 -0700</bug_when>
    <thetext>I don&apos;t know if this should be a separate ticket, but the same issue happens with HEVC/h265 on Safari Technology Preview Release 181 (Safari 17.4, WebKit 19618.1.3.1)

Repro is the same except choose h265 before clicking start. VP8, VP9, and AV1 all run successfully with no out-of-order errors</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1994090</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-11-20 23:52:58 -0800</bug_when>
    <thetext>Committed 271004@main (cf345a7967b3): &lt;https://commits.webkit.org/271004@main&gt;

Reviewed commits have been landed. Closing PR #19725 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1999316</commentid>
    <comment_count>7</comment_count>
    <who name="Marcello Bastea-Forte">marcello</who>
    <bug_when>2023-12-13 10:04:05 -0800</bug_when>
    <thetext>How do I run the webkit nightly build? 

I just tried Safari Technical Preview Release 184 (Safari 17.4, WebKit 19618.1.7.1.1) and still see the bug, but not sure if this fix is in there?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2001824</commentid>
    <comment_count>8</comment_count>
    <who name="Marcello Bastea-Forte">marcello</who>
    <bug_when>2023-12-24 09:52:47 -0800</bug_when>
    <thetext>Also still broken on Release 185 (Safari 17.4, WebKit 19618.1.9.8)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005345</commentid>
    <comment_count>9</comment_count>
    <who name="Marcello Bastea-Forte">marcello</who>
    <bug_when>2024-01-16 12:45:05 -0800</bug_when>
    <thetext>Also still broken on Safari Technical Preview Release 186 (Safari 17.4, WebKit 19618.1.10.1.1) on macOS Sonoma 14.1.2 (23B92)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2009129</commentid>
    <comment_count>10</comment_count>
    <who name="Marcello Bastea-Forte">marcello</who>
    <bug_when>2024-01-30 15:48:01 -0800</bug_when>
    <thetext>Still broken on Safari Technical Preview Release 187 (Safari 17.4, WebKit 19619.0.1.2) on Sonoma 14.1.2 (23B92)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011741</commentid>
    <comment_count>11</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-02-08 07:37:48 -0800</bug_when>
    <thetext>I filed https://bugs.webkit.org/show_bug.cgi?id=268987 to keep track of this, it seems additional work is needed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>