Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The localized fixes preserve picker selection, address the reported failures, and include targeted regression coverage with no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes WebAssembly picker support reporting and Safari download failures for #24130, #25683, and #25684, following the chunked-storage changes in #23880.
Changes:
- Aligns file-picker support checks with the implementation selected by
WasmConfiguration. - Uses in-memory downloads when writable storage is unavailable and copies partial chunks to prevent Safari zero-padding.
- Adds regression tests and updates capability and provider documentation.
| File | Description |
|---|---|
| src/Uno.WinRT/ts/Windows/Storage/Streams/NativeChunkedBuffer.ts | Fixes writable-storage detection and partial-chunk downloads. |
| src/Uno.WinRT/Storage/Pickers/FileSavePicker.wasm.cs | Shares implementation selection with save support checks. |
| src/Uno.WinRT/Storage/Pickers/FileOpenPicker.wasm.cs | Shares implementation selection with open support checks. |
| src/Uno.UI.RuntimeTests/Windows/Storage/Pickers/Given_FileSystemAccessApiInformation.cs | Tests picker support and downloaded content integrity. |
| src/Uno.UI.Runtime.WebAssembly.Browser/Storage/Pickers/FileSystemAccessApiInformation.cs | Reports support for configured native or fallback file pickers. |
| doc/articles/features/windows-storage-pickers.md | Clarifies support semantics, provider IDs, and configuration options. |
Review effort: Balanced
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25685/docs/index.html |
|
Tick the box to add this pull request to the merge queue (same as
|
MartinZikmund
left a comment
There was a problem hiding this comment.
@mikernet thanks a lot for this one, and for the very thorough Safari testing. The TS fixes look right to me: the createWritable feature check routes Safari 15.2-18 to the existing in-memory Blob path, the partial-chunk slice is the minimal workaround for the WebKit bug (one copy of at most 2 MB per file), and the commit flow is untouched, so the download still fires exactly once per CompleteUpdatesAsync. The GetImplementation() refactor keeping IsSupported() and the actual dispatch in sync is nice too. It also merges cleanly next to #25672 (different hunk in FileSavePicker.wasm.cs).
One thing I'd like to settle before merging, inline below: after this change there is no longer any way to ask "is the File System Access API available?" before picking, on a class literally named FileSystemAccessApiInformation.
The Android and iOS builds of Uno.WinRT have no WasmPickerConfiguration, but they load every type of the runtime test assembly. The enum in the DataRow arguments, test method parameters and the DownloadAsync state machine made that fail with a ReflectionTypeLoadException, so no runtime test ran on those targets. Pass the configuration by name and touch the enum only in a non-async helper's body.
IsOpenPickerSupported and IsSavePickerSupported now also count the upload and download pickers, so an app could no longer tell before picking whether a saved file can be written again in place or each commit becomes a new download. IsNativeOpenPickerSupported and IsNativeSavePickerSupported keep that answer: whether the browser has the File System Access API file pickers, whatever WasmConfiguration says. The docs point the "Save As only" case at them and spell out that IsFolderPickerSupported is about the File System Access API. BREAKING CHANGE: On WebAssembly, FileSystemAccessApiInformation's IsOpenPickerSupported, IsSavePickerSupported and AreFilePickersSupported report whether the pickers can be used under the current WasmConfiguration, so they are true in browsers without the File System Access API pickers when WasmConfiguration includes DownloadUpload (the default). Use IsNativeOpenPickerSupported and IsNativeSavePickerSupported to check for the File System Access API pickers.
|
Agreed, the old answer should stay reachable. Done in 5c66af1:
Behavior change: the PR checklist now says what changed next to the unticked "NO breaking changes" box, and the commit has a Separately, in e8cc8fd: the tests used |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25685/docs/index.html |
GitHub Issue:
Fixes #24130
Fixes #25683
Fixes #25684
PR Type:
🐞 Bugfix
What changed? 🚀
Saving through
FileSavePickeron WebAssembly had three problems in browsers without the File System Access API, where it falls back to the download picker:IsSavePickerSupportedreportedfalsewhere saving works ([WASM] False negative FileSystemAccessApiInformation.IsSavePickerSupported #24130). It only checked forshowSaveFilePicker, so it wasfalsein Brave, Firefox and Safari although the defaultWasmPickerConfiguration.FileSystemAccessApiWithFallbacksaves there with the download picker.IsOpenPickerSupportedhad the same problem with the upload picker.TypeError: handle.createWritable is not a functionon Safari 15.2 to 18 #25683). The download picker stages the file in the origin-private file system (OPFS) since fix(wasm): Stop buffering whole files in tab memory on StorageFile writes #23880, and only built the download in memory when there was no OPFS. Safari 15.2 to 18 hasnavigator.storage.getDirectory()but noFileSystemFileHandle.createWritable(added in Safari 26), soCachedFileManager.CompleteUpdatesAsyncfailed withTypeError: handle.createWritable is not a function. This is the iOS 16 failure in [WASM] False negative FileSystemAccessApiInformation.IsSavePickerSupported #24130. iOS 17 and 18 failed the same way.byteOffsetandbyteLength(WebKit bug 302733). The staging wrote the last, partial 2 MB chunk assubarray(0, n), so every file was padded with zeros to a multiple of 2 MB: a 16-byte file was saved as 2,097,152 bytes, and a 4,206,649-byte file as 6,291,456 bytes.Fixes
createWritable: the download picker now also builds the download in memory whencreateWritableis missing, as it already did without OPFS. Saving therefore works in Safari 15.2 to 18, andIsSavePickerSupportedistruethere, like in every other browser where saving works. Reportingfalsethere would have meant keeping saving broken on iOS 16 to 18, while the in-memory download, the path browsers without OPFS take, works there.Uint8Arraywith its own buffer, so Safari writes exactly that chunk. The copy isn't limited to Safari: it is correct in every browser, costs at most one copy of the partial last chunk per file, and needs no change once WebKit fixes its bug.IsOpenPickerSupportedandIsSavePickerSupportednow report whether the picker can be used under the currentWasmConfiguration: with the File System Access API when that is enabled and available, or with the upload or download picker when that is enabled. Each picker now chooses its implementation through one helper, which itsIsSupported()uses too, so the two can't drift apart.AreFilePickersSupportedfollows them.IsFolderPickerSupportedis unchanged;FolderPickerhas no other implementation.IsNativeOpenPickerSupportedandIsNativeSavePickerSupportedreport whether the browser has the File System Access API file pickers, whateverWasmConfigurationsays, which is whatIsOpenPickerSupportedandIsSavePickerSupportedreported before. An app can still decide before picking whether to offer an in-place Save (a File System Access API file can be written again) or only Save As (each commit of a download picker file is a new download).WasmConfigurationIsSavePickerSupportedbeforetruetruefalsetruefalsetruefalsetrueTypeErroron commitDownloadUploadtrueFileSystemAccessApifalsefalseNotSupportedExceptionNotSupportedExceptionThe docs section that described these properties as File System Access API checks now describes what they report, points the "Save As only" case at
IsNativeSavePickerSupported, and says thatIsFolderPickerSupported, unlike the file picker checks, is about the File System Access API. It keeps its old anchor,#checking-whether-file-system-access-api-is-supported, for existing links. It also lists the download picker's provider ID next to the other two, sinceStorageFile.Provider.Idis what tells a File System Access API file (jsfileaccessapi) from a download picker file (wasmdownloadpicker). The list ofWasmConfigurationvalues, which was missing the space after each bullet and rendered as plain text, is now a list.Tests
The new
Given_FileSystemAccessApiInformationruntime tests run on Skia WebAssembly only:When_Download_Upload_Pickers_Are_Enabled_Then_File_Pickers_Are_Supported: the three properties, withFileSystemAccessApiWithFallbackand withDownloadUpload(6 rows).When_Only_File_System_Access_Api_Is_Enabled_Then_Support_Follows_The_Browser: withFileSystemAccessApi, the properties followshowOpenFilePickerandshowSaveFilePicker(2 rows).When_Native_Support_Is_Checked_Then_It_Follows_The_Browser_Whatever_The_Configuration:IsNativeOpenPickerSupportedandIsNativeSavePickerSupportedfollowshowOpenFilePickerandshowSaveFilePickerwithFileSystemAccessApiWithFallbackand withDownloadUpload(4 rows).When_Download_Is_Committed_Then_The_Browser_Downloads_The_Content: picks a file with the download picker, writesHello, world!, commits it and checks the download's name and content (2 rows).When_Download_Spans_Several_Chunks_Then_The_Browser_Downloads_All_Of_It: the same with 4,206,649 bytes (two full chunks and a partial one) and with exactly two chunks, checking the download's length and hash (3 rows).The download tests record the download instead of starting it. One row of each hides
createWritable, as in Safari 15.2 to 18.WasmPickerConfigurationonly exists in the__CROSSRUNTIME__build of Uno.WinRT, while the runtime test assembly is also loaded on Android and iOS. The tests therefore pass the configuration by name and use the enum only inside a helper's body, so the assembly's types still load there.With the
IsNativeOpenPickerSupportedandIsNativeSavePickerSupportedtests added, all 17 tests pass in Chrome and in Chrome with--disable-blink-features=FileSystemAccessLocal. Made to returnIsSupported()instead, the four new rows fail in the latter (trueinstead offalse).Headless Chrome has the File System Access API pickers, so the support tests only fail without the fix in a browser without them. I ran them in Chrome with
--disable-blink-features=FileSystemAccessLocal, which removes those pickers as Brave does, and in Safari in the iOS simulator. Results for the 13 tests other than theIsNative...ones, which came later (SamplesAppbrowserwasm):createWritablefail:TypeError: handle.createWritable is not a functioncreateWritablefailcreateWritable(TypeError) and the two partial-chunk downloads fail (2,097,149 characters instead of 13, and 6,291,456 bytes instead of 4,206,649)All 271
Windows_Storageruntime tests pass with the fix in headless Chrome (270 passed, 1 skipped). I couldn't run Safari 15.2 to 18, since no simulator runtime for those versions is installed here, nor Firefox or Brave itself. HidingcreateWritablein Safari 26 and 27 covers the same code path.PR Checklist ✅
Screenshots Compare Test Runresults.IsOpenPickerSupported,IsSavePickerSupportedandAreFilePickersSupportednow count the upload and download pickers, see below)Behavior change:
IsOpenPickerSupported,IsSavePickerSupportedandAreFilePickersSupportedused to report whether the File System Access API pickers are present. Apps that used them that way now gettruein browsers that only have the download and upload pickers. To check for the File System Access API pickers before picking, use the newIsNativeOpenPickerSupportedandIsNativeSavePickerSupported. Whether a picked file came from the File System Access API is still given by itsProvider.Id. With theFileSystemAccessApiconfiguration, the old properties still report the File System Access API pickers.