Skip to content

[WASM] Files saved through the download fallback are padded with zeros on Safari 26+ #25684

Open

Description

@mikernet

Current behavior 🐛

On Safari 26 and later, every file saved with FileSavePicker through the download fallback is padded with zeros to a multiple of 2 MB:

  • a 16-byte file ("Hello, world!" written with FileIO.WriteTextAsync, so with a UTF-8 BOM) is saved as 2,097,152 bytes;
  • a 4,206,649-byte file is saved as 6,291,456 bytes.

The download picker stages the file in the origin-private file system in 2 MB chunks (#23880) and writes the last, partial chunk as chunk.subarray(0, n). Safari's FileSystemWritableFileStream.write() writes a view's whole underlying buffer, ignoring its byteOffset and byteLength: WebKit bug 302733, "FileSystemWritableFileStream.write() ignores byteOffset when writing TypedArray subarrays". So the whole 2 MB chunk is written, zeros included.

Seen in Safari 26.0.1 and 27.0 (iOS simulator) and 27.0.1 (macOS). Chrome writes only the view, so the saved file is correct there.

Expected behavior 🎯

The saved file has exactly the bytes that were written.

How to reproduce it (as minimally and precisely as possible) 🔬

In a WebAssembly app with the default WasmPickerConfiguration.FileSystemAccessApiWithFallback, served over HTTPS or from localhost, run in Safari 26 or later:

var picker = new FileSavePicker { SuggestedFileName = "Report" };
picker.FileTypeChoices.Add("Text", new List<string> { ".txt" });

var file = await picker.PickSaveFileAsync();
CachedFileManager.DeferUpdates(file);
await FileIO.WriteTextAsync(file, "Hello, world!");
await CachedFileManager.CompleteUpdatesAsync(file);

The downloaded Report.txt is 2,097,152 bytes long instead of 16.

Workaround 🛠️

No response

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

WebAssembly

Uno.Sdk version (and other relevant versions) 📦

Reproduced in the SamplesApp built from master (ab14387) and from 6.8.0-dev.222 (Uno.Sdk 6.8.0-dev.66). The staging has been there since #23880.

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

I'll open a PR that also fixes #24130.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions