Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Browser Crash with large files #287

Open
ghost opened this issue Jul 14, 2022 · 4 comments
Open

iOS Browser Crash with large files #287

ghost opened this issue Jul 14, 2022 · 4 comments

Comments

@ghost
Copy link

ghost commented Jul 14, 2022

Hi, I found your library very interesting and today I used your examples page to perform some test before integrate it in my website. Specifically I was using this: https://jimmywarting.github.io/StreamSaver.js/examples/plain-text.html

I have found some problem with my iPhone XS Max equipped with iOS 15.4 both with Safari and Google Chrome. In particular the browser crash and it will refresh the page.

Here the steps to reproduce the issue:

  1. Open the link above from your iPhone with Safari or Google Chrome

  2. Click on "Write a lot of Lorem ipsum" and leave the default value (1024)

  3. Wait some seconds and hit the "Close" button

  4. The browser does not prompt you anything but instead a refresh (crash) is made

I've noticed that with 512mb the issue is no more present with Safari. Instead Chrome is not able to reach the requested page (crash).
You can also test this issue with an emulator on xcode but by downloading a 10gb file.

I hope that this can be fixed in some way :)

@jimmywarting
Copy link
Owner

Hi, safari dose not use the same solution as the other browsers, b/c it can't download something generated from the service worker... so it fallbacks to building a blob and saves it using a[download=filename][href=blob:url] links instead.

apparently someone have just reported that the new version of safari do have support for downloading stuff generated by a service worker in #69 so perhaps maybe we don't need the blob fallback any more.

But I might know another possible way to improve the blob fallback method. And I would be glad if you could test it for me (as i do not have an iphone myself)
At this line:

chunks.push(chunk)

could you change it to:

- chunks.push(chunk) 
+ chunks.push(new Blob(chunk))

Doing this can potentially give browser time to off-load some memory data to the disc when it isn't needed. Not all browser dose this but browser can be a bit more clever when it comes to handle blob in the background

PS: chrome on iphone is basically just safari with a skin on top. Apple do not allow other engines to run on iOS such as chromium or firefox... they must use webkit's engine.

@ricktorrero
Copy link

I tried your change on both iOS and macOS
chunks.push(new Blob(chunk))

but it failed as well

I also tried the code as it is just removing the useBlobFallback condition for safari
and got an error on
mc.port1.postMessage(readable, [readable])
saying that

it cannot be cloned

I noticed that you mention an idea removing PostMessage I tried to understand how to changed it but failed.

@ghost
Copy link
Author

ghost commented Jul 14, 2022

Unfortunately with this modifications it seems that the browser freezes at the beginning of the download and after a few seconds it crashes

@Antoine340
Copy link

Hello,

Safari > 15.4 is working with StreamSaver for large files (more than 500MB). As download from service workers are supported.
On Safari IOs you'll have '.html' added to the end of the filename if you use the default 'octet/stream' type ( try to detect MIME type ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants