Skip to content

fix(wasm): Don't double the download file extension - #25672

Merged
MartinZikmund merged 5 commits into
unoplatform:masterfrom
mikernet:dev/mikernet/wasm-download-extension
Nov 24, 2026
Merged

MartinZikmund merged 5 commits into
unoplatform:masterfrom
mikernet:dev/mikernet/wasm-download-extension

Conversation

@mikernet

@mikernet mikernet commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25671

PR Type:

🐞 Bugfix

What changed? 🚀

When the browser has no File System Access API (Firefox, Safari, Brave and others), FileSavePicker falls back to the download picker. That fallback always appended the first FileTypeChoices extension to SuggestedFileName, so Report.pdf with a .pdf choice was downloaded as Report.pdf.pdf.

The download picker now follows the rule that the File System Access API path (FileSavePicker.ts) and the Android picker already follow: a name that already ends with one of the FileTypeChoices extensions (case-insensitive) is kept as is, with its own casing. Otherwise the first extension of the first choice is appended, as before.

SuggestedFileName FileTypeChoices Before After
Report.pdf PDF: .pdf Report.pdf.pdf Report.pdf
Report.PDF PDF: .pdf Report.PDF.pdf Report.PDF
Report.txt PDF: .pdf; Text: .txt, .text Report.txt.pdf Report.txt
Report.text PDF: .pdf; Text: .txt, .text Report.text.pdf Report.text
Report PDF: .pdf Report.pdf Report.pdf
Report.txt PDF: .pdf Report.txt.pdf Report.txt.pdf
(empty) PDF: .pdf <GUID>.pdf <GUID>.pdf

A name whose extension none of the choices has (Report.txt with only a PDF choice) still gets the first choice's extension appended, as on the File System Access API path and on Android. What the WinUI picker does with such a name isn't documented, so that case is unchanged.

When SuggestedSaveFile is set, the download picker still returns it, unchanged.

The new Given_FileSavePicker_Download runtime tests run on Skia WebAssembly only. They pick a file with the download picker and check its name. The picker returns its file without showing anything, so the tests run unattended. Four cases cover the names that keep their extension, and two the names that still get the first choice's extension (Report and Report.txt with only a PDF choice). I ran them locally (SamplesApp browserwasm, headless Chrome). Without the fix, the four keep cases fail (Report.pdf.pdf, Report.PDF.pdf, Report.txt.pdf, Report.text.pdf). With the fix, all six pass. The two append rows pass with and without the fix, since that behavior is unchanged; a mutation that keeps any name with an extension as is (Path.HasExtension) fails the Report.txt row.

WasmPickerConfiguration only 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.

PR Checklist ✅

Copilot AI balanced review requested due to automatic review settings October 24, 2026 01:31
@github-actions github-actions Bot added the platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform label Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix matches the requested behavior and has targeted regression coverage, with only a nonblocking test-metadata nit remaining.

1 open issue
What changed in this PR

Fixes #25671 by preventing the WebAssembly download fallback from duplicating a recognized file extension, aligning it with the existing native-picker path.

Changes:

  • Preserves suggested names ending in any allowed extension, using case-insensitive matching.
  • Retains first-extension appending when no allowed extension matches.
  • Adds four unattended Skia WebAssembly regression cases.
File Description
src/​Uno.WinRT/​Storage/​Pickers/​FileSavePicker.wasm.cs Checks allowed extensions before appending the default extension.
src/​Uno.UI.RuntimeTests/​Windows/​Storage/​Pickers/​Given_FileSavePicker_Download.cs Tests extension preservation, including casing and alternate choices.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 24, 2026 01:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrowly scoped fix matches the reported requirements, and the regression tests cover the changed behavior with no identified blocking issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@MartinZikmund MartinZikmund left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mikernet, nice and tight fix. The download fallback now uses the same case-insensitive endsWith rule as FileSavePicker.ts, and multi-dot names (archive.tar.gz with .gz or .tar.gz) are handled sensibly too. I checked it against #25685: the two touch different parts of FileSavePicker.wasm.cs and merge cleanly. #25685's download tests use a bare Report name, so this PR doesn't affect them.

Optional nit: a data row or two for the append path (Report -> Report.pdf, and Report.txt with only a PDF choice -> Report.txt.pdf) would lock in the behavior the PR deliberately leaves unchanged.

@MartinZikmund

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 247927 found UI Test snapshots differences: skia-linux-screenshots: 252, skia-windows-screenshots: 381

Details
  • skia-linux-screenshots: 252 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_Showcase.png
    • AnimatedVisualsTestbedPage.png
    • AnimatedBackVisualSourceSamplePage.png
    • AppWindowTitleBar Properties.png-dark
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • Accessibility_Showcase.png-dark
    • Basics.png-dark
    • Basics.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CompositionNineGridBrush_Source_Changes.png-dark
  • skia-windows-screenshots: 381 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedVisualsTestbedPage.png-dark
    • AutomationProperties_AutomationId.png
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationProperties_AutomationId.png-dark
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • AutomationProperties_StructureAndProps.png-dark

The download picker still adds the first choice's extension when the
suggested name doesn't end with any choice's extension, including a
name with another extension. Lock that in next to the rows for names
that keep their extension.
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
PickNameAsync 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.
auto-merge was automatically disabled November 20, 2026 21:01

Head branch was pushed to by a user without write access

@mikernet

Copy link
Copy Markdown
Contributor Author

Added the two rows for the append path in 22b71e0: Report -> Report.pdf, and Report.txt with only a PDF choice -> Report.txt.pdf.

The red Android and iOS lanes were caused by this PR. Every shard failed before running a single test, in UnitTestsControl.InitializeTests, with ReflectionTypeLoadException: Could not load type 'Uno.WasmPickerConfiguration' from assembly 'Uno.WinRT'. That enum is __CROSSRUNTIME__ only, so the Android and iOS builds of Uno.WinRT don't have it, but the runtime test assembly is loaded on every target, and the compiler-generated state machine of PickNameAsync had a field of that type. Fixed in 1482d5b: the configuration is passed by name and the enum only appears in a non-async helper's body, so nothing outside a method body refers to it. #25685 had the same problem in its tests; it's fixed there too.

The other two red jobs are unrelated:

  • WebAssembly WebGPU 8: RadioButtonsInteractionTests.ScrollViewerSettingSelectionDoesNotMoveFocus fails the same way on master and on the other PR builds from today.
  • Desktop Windows WebGPU: Given_CoreWebView2Profile.When_BrowserProcessId_Is_Reported, a WebView2 test.

@MartinZikmund

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 248653 found UI Test snapshots differences: skia-linux-screenshots: 254, skia-windows-screenshots: 261

Details
  • skia-linux-screenshots: 254 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • AutomationProperties_StructureAndProps.png-dark
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AppWindowTitleBar Properties.png
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest2.png-dark
    • Basics.png-dark
    • BasicAcrylicBrushTest2.png
    • Basics.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CompositionNineGridBrush_Source_Changes.png-dark
  • skia-windows-screenshots: 261 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppWindowTitleBar Properties.png-dark
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Basics.png-dark
    • Basics.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AnimatedBackVisualSourceSamplePage.png
    • AppWindowTitleBar Properties.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png

@MartinZikmund
MartinZikmund merged commit 11e833a into unoplatform:master Nov 24, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WASM] FileSavePicker download fallback doubles the extension of SuggestedFileName

5 participants