Bug 262950 - WebCodecs HEVC isSupported returns true but decoding failed
Summary: WebCodecs HEVC isSupported returns true but decoding failed
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified macOS 13
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-10-10 04:16 PDT by zzy8200
Modified: 2023-12-25 09:40 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zzy8200 2023-10-10 04:16:59 PDT
With Safari Technology Preview,

const decoder_config = {
     codec: "hev1.1.6.L90.90",
     hardwareAcceleration: "no-preference"
};
(await VideoDecoder.isConfigSupported(decoder_config)).supported // returns True

But then, decoding HEVC failed with error: Unhandled Promise Rejection: EncodingError: Decoder failure.

I made a minimum reproduce page: https://zeruniverse.github.io/webcodecs_bg_hevc_test/new.html
and HEVC file sample: https://zeruniverse.github.io/webcodecs_bg_hevc_test/sample.hevc

Same page works in Chrome 117 on both Windows and MacOS
Comment 1 Alexey Proskuryakov 2023-10-10 15:14:30 PDT
I can reproduce with STP 179, but not with system Safari that I have on my machine.
Comment 2 Radar WebKit Bug Importer 2023-10-10 15:14:52 PDT
<rdar://problem/116768196>
Comment 3 Alexey Proskuryakov 2023-10-10 15:18:22 PDT
This could be simply because WebCodec HEVC is a feature in Preview state, so it's only enabled in STP.

But if so, it probably shouldn't be in Preview state if it doesn't work at all.
Comment 4 zzy8200 2023-10-10 19:30:30 PDT
(In reply to Alexey Proskuryakov from comment #1)
> I can reproduce with STP 179, but not with system Safari that I have on my
> machine.

My system Safari raises different exception:

const decoder_config = {
     codec: "hev1.1.6.L90.90",
     hardwareAcceleration: "no-preference"
};

// error: invalid config
(await VideoDecoder.isConfigSupported(decoder_config)).supported

I think it would be better just return supported = False instead of throwing an error
Comment 5 youenn fablet 2023-12-04 01:21:37 PST
Trying in Chrome 119, I also get an EncodingError, like in STP 182.
Both are using VideoToolBox which returns a -12909 error.

I do not think this is a regression.
Could it be that the havoc sample is not fully aligned with the standard?
Comment 6 zzy8200 2023-12-04 09:09:02 PST
(In reply to youenn fablet from comment #5)
> Trying in Chrome 119, I also get an EncodingError, like in STP 182.
> Both are using VideoToolBox which returns a -12909 error.
> 
> I do not think this is a regression.
> Could it be that the havoc sample is not fully aligned with the standard?

This is weird since Chrome 117 works. Anyway, I made a new HEVC sample file which now works on MacOS 14.1 + Chrome 119, BUT FAILS ON STP.

The sample link is same: https://zeruniverse.github.io/webcodecs_bg_hevc_test/new.html

with file: https://zeruniverse.github.io/webcodecs_bg_hevc_test/sample.hevc
Comment 7 youenn fablet 2023-12-08 01:47:42 PST
Pull request: https://github.com/WebKit/WebKit/pull/21496
Comment 8 EWS 2023-12-08 06:51:56 PST
Committed 271728@main (8555adfc8a29): <https://commits.webkit.org/271728@main>

Reviewed commits have been landed. Closing PR #21496 and removing active labels.
Comment 9 zzy8200 2023-12-25 09:40:20 PST
This fix does NOT fully solve the problem. For each frame, if I just display the frame to Canvas, it looks correct but since the sample HEVC is CT file sliced along z-axis. If I stack the frames up and cut along z-axis, it should still look good.

You may check https://zeruniverse.github.io/webcodecs_bg_hevc_test/new.html

The first group of 268 images are just decoded frames.

The second group of 268 images are generated by stacking those frames together along a new axis and then slice the cube using plane parallel to the new axis.

If you open the above webpage in Chrome, all looks good.

If you open the above webpage in STP 185, the first 268 images looks good (but actually if you check first non-black image, it looks different from that in Chrome. I decoded that image in FFMPEG, the Chrome result is correct), the second 268 images looks weird.

I suspect something is still wrong.