Bug 234940

Summary: DataURLResourceMediaLoader decodes the URL repeatedly during a video playback
Product: WebKit Reporter: Peng Liu <peng.liu6>
Component: New BugsAssignee: Peng Liu <peng.liu6>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, eric.carlson, jean-yves.avenard, jer.noble, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=235325
Attachments:
Description Flags
[fast-cq] Patch none

Peng Liu
Reported 2022-01-06 17:16:49 PST
DataURLResourceMediaLoader decodes the URL repeatedly during a video playback
Attachments
[fast-cq] Patch (2.92 KB, patch)
2022-01-06 17:37 PST, Peng Liu
no flags
Peng Liu
Comment 1 2022-01-06 17:37:11 PST
Created attachment 448550 [details] [fast-cq] Patch
Peng Liu
Comment 2 2022-01-06 17:38:06 PST
Jean-Yves Avenard [:jya]
Comment 3 2022-01-06 18:27:01 PST
Comment on attachment 448550 [details] [fast-cq] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=448550&action=review > Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:365 > + if (!m_dataURLMediaLoader && [contentInfo respondsToSelector:@selector(setEntireLengthAvailableOnDemand:)]) couldn't we cache the URL decoding instead and re-use that ?
Peng Liu
Comment 4 2022-01-07 09:00:40 PST
(In reply to Jean-Yves Avenard [:jya] from comment #3) > Comment on attachment 448550 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=448550&action=review > > > Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:365 > > + if (!m_dataURLMediaLoader && [contentInfo respondsToSelector:@selector(setEntireLengthAvailableOnDemand:)]) > > couldn't we cache the URL decoding instead and re-use that ? Actually, this is what this patch does. AVFoundation caches the decoded result internally. Some refactoring is needed if we want to cache the result in WebKit.
Darin Adler
Comment 5 2022-01-11 11:19:59 PST
Comment on attachment 448550 [details] [fast-cq] Patch Can we find a way to test this?
Peng Liu
Comment 6 2022-01-11 15:22:37 PST
(In reply to Darin Adler from comment #5) > Comment on attachment 448550 [details] > Patch > > Can we find a way to test this? This patch fixes a performance issue. I manually tested it. But I am not sure we can add a reliable regression test for it.
EWS
Comment 7 2022-01-11 15:26:24 PST
Committed r287899 (245936@main): <https://commits.webkit.org/245936@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 448550 [details].
Darin Adler
Comment 8 2022-01-11 16:34:13 PST
We have other tests for performance issues. I’m surprised to hear we can’t make a test for this one.
Peng Liu
Comment 9 2022-01-11 17:04:54 PST
(In reply to Darin Adler from comment #8) > We have other tests for performance issues. I’m surprised to hear we can’t > make a test for this one. Do you mean regression tests which run automatically on bots?
Darin Adler
Comment 10 2022-01-11 17:41:00 PST
Yes. There are a few in LayoutTests/perf for example.
Peng Liu
Comment 11 2022-01-12 08:59:30 PST
(In reply to Darin Adler from comment #10) > Yes. There are a few in LayoutTests/perf for example. Thanks! These tests look useful! However, the test for this patch is more difficult. Because the performance issue is related to AVFoundation's internal behavior, and there is no obvious way to get the performance difference (before and after applying this patch) from JS code.
Darin Adler
Comment 12 2022-01-12 09:59:01 PST
I’m willing to accept no for an answer. But I really don’t understand why we can’t create a test; every kind of test we have originally did not exist, and was invented because we needed to protect the performance or reliability of WebKit in the long run. Presumably we can make a huge stress test case where the performance impact is very obvious, and make a way to run it. Given the fix here is subtle, and depends on both WebKit and AVFoundation, I think it’s really risky to just make the fix without creating a regression test.
Peng Liu
Comment 13 2022-01-18 12:42:07 PST
(In reply to Darin Adler from comment #12) > I’m willing to accept no for an answer. > > But I really don’t understand why we can’t create a test; every kind of test > we have originally did not exist, and was invented because we needed to > protect the performance or reliability of WebKit in the long run. Presumably > we can make a huge stress test case where the performance impact is very > obvious, and make a way to run it. > > Given the fix here is subtle, and depends on both WebKit and AVFoundation, I > think it’s really risky to just make the fix without creating a regression > test. I am working on a regression test now. Eric and Jer provided some good suggestions. https://bugs.webkit.org/show_bug.cgi?id=235325
Note You need to log in before you can comment on or make changes to this bug.