flet build: deterministic, decodable icon/splash image selection - #6707
Merged
Conversation
find_platform_image picked the first glob.glob() match when multiple files shared a base name (e.g. icon.png + icon.svg). glob order is filesystem-dependent, so the same app could pick icon.png on one machine and icon.svg on another; SVG can't be decoded by flutter_launcher_icons / flutter_native_splash, so it crashed with NoDecoderForImageFormatException. Now filter to decodable formats (.svg dropped everywhere; .icns macOS-only, .ico Windows-only) and rank so a raster image (.png first) always wins, making the choice deterministic. When only an SVG is supplied, skip it with a build-log warning and fall back to the default icon instead of crashing.
Deploying flet-website-v2 with
|
| Latest commit: |
53d053a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a8d2cd16.flet-website-v2.pages.dev |
| Branch Preview URL: | https://feature-icon-format-selectio.flet-website-v2.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
flet buildcould crash with a machine-dependentNoDecoderForImageFormatExceptionfromflutter_launcher_icons. When an app'sassets/held several files sharing a base name — e.g. bothicon.pngandicon.svg—find_platform_imageselectedimages[0]fromglob.glob(...), whose order is filesystem-dependent. So the same app could pickicon.pngon one machine andicon.svgon another. SVG is vector and can't be decoded by the raster icon/splash generators (flutter_launcher_icons,flutter_native_splash), turning a working build into a crash purely based on directory-listing order.This showed up in the wild: an app that built fine locally failed on a fresh CI/cloud builder, both with the identical
assets/icon.png+assets/icon.svg.Fix
In
find_platform_image:.svgis dropped everywhere (never decodable);.icnsstays macOS-only and.icoWindows-only (unchanged)..pngfirst), independent of glob/filesystem order — soicon.pngalways beatsicon.svgwhen both exist.Noneis returned, sofallback_imageleaves the template default in place and the default Flet icon is used instead of crashing.Applies to both icons and splash images (both generators are raster-only).
Tests
Adds
tests/test_find_platform_image.py(5 cases): raster-over-SVG preference,.pngranked over other raster, SVG-only →None+ warning, no-candidates → silentNone, and.icobeing Windows-only.Targets the 0.86.3 milestone.
Summary by Sourcery
Ensure flet build deterministically selects decodable raster icons/splash images per platform to avoid crashes when multiple formats share a base name.
Bug Fixes:
Documentation:
Tests: