Bug 235448 - file.stream() is slow and CPU-bound
Summary: file.stream() is slow and CPU-bound
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 15
Hardware: Mac (Apple Silicon) macOS 12
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-21 11:05 PST by Jacob Bandes-Storch
Modified: 2022-01-24 14:28 PST (History)
5 users (show)

See Also:


Attachments
Screen recording demonstrating the issue (9.40 MB, video/quicktime)
2022-01-21 11:05 PST, Jacob Bandes-Storch
no flags Details
Patch (5.14 KB, patch)
2022-01-24 10:25 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (5.16 KB, patch)
2022-01-24 11:28 PST, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Bandes-Storch 2022-01-21 11:05:13 PST
Created attachment 449672 [details]
Screen recording demonstrating the issue

Also filed as FB9854642

Reading a file with file.stream() is much slower than repeatedly calling file.slice().

1. Visit https://jsfiddle.net/0hnembvu/21/
2. Choose a large file (~200MB). Observe the progress bar updates smoothly, and the file can be read in ~200ms.
3. Reload the page.
4. Enable the "use ReadableStream API" checkbox.
5. Choose the same large file again. Observe the page becomes unresponsive while reading (the progress bar does not update smoothly) and the file takes much longer to read (~1500ms).
Comment 2 Radar WebKit Bug Importer 2022-01-24 10:25:46 PST
<rdar://problem/87977499>
Comment 3 youenn fablet 2022-01-24 10:25:53 PST
Created attachment 449827 [details]
Patch
Comment 4 Alex Christensen 2022-01-24 11:22:27 PST
Comment on attachment 449827 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=449827&action=review

> Source/WebCore/fileapi/Blob.cpp:273
>                  return;

This is a little strange.  There is nothing after this now.
Comment 5 youenn fablet 2022-01-24 11:28:08 PST
Created attachment 449836 [details]
Patch for landing
Comment 6 EWS 2022-01-24 13:13:50 PST
Committed r288463 (246349@main): <https://commits.webkit.org/246349@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449836 [details].
Comment 7 Jacob Bandes-Storch 2022-01-24 14:28:58 PST
Amazing turnaround time! :D