| Summary: | ServiceWorker downloads fail when chunks are sent via postMessage | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | mrskman |
| Component: | Service Workers | Assignee: | youenn fablet <youennf> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | ap, cdumez, mark.lam, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 16 | ||
| Hardware: | iPhone / iPad | ||
| OS: | iOS 16 | ||
|
Description
mrskman
2023-05-12 05:06:02 PDT
This sounds like the ServiceWorker process running out of memory. I didn't analyze the test, but is it holding to the downloaded data permanently in RAM? If not, going be a garbage collection problem. No, ServiceWorker isn't holding the downloaded data permanently. It holds one chunk at a time in Test #3. The Test #3 works like this: 1) Web page downloads a chunk as a Blob. 2) Blob is passed to the ServiceWorker via postMessage. 3) ServiceWorker converts it to ArrayBuffer. 4) ServiceWorker waits until ReadableStream requests a new chunk via pull method. 5) ServiceWorker passes the ArrayBuffer to ReadableStream. 6) ServiceWorker sends message back to the page via MessageChannel. 7) Page receives the message and goes to step 1) until the download is completed. I tried to reproduce now but I do not think I reproduced precisely the issue. I did not see increase of memory usage. Another possibility is that the service worker process is getting suspended, but not the web page somehow. I'll continue trying to reproduce a bit. @mrksman, if you can reproduce easily, can you send me a sysdiagnose (youenn@apple.com) with the timestamp of the bug? @mrskman sent me a sysdiagnose. The networking process gets jetsamed, which triggers stopping the service workers and failing the download: 2023-05-22 11:34:42.517896+0200 0x327 Default 0x0 0 kernel: (kernel) memorystatus: killing process 5169 [com.apple.WebKit.Networking] in high band FOREGROUND (100) - memorystatus_available_pages: 36200 It seems we have a memory leak with URLKeepingBlobAlive isolatedCopy(). Pull request: https://github.com/WebKit/WebKit/pull/14184 Committed 264412@main (fb9630a9c9fc): <https://commits.webkit.org/264412@main> Reviewed commits have been landed. Closing PR #14184 and removing active labels. Thank you for patching this issue! How long does it usually take to get a patch to iOS? |