-
Notifications
You must be signed in to change notification settings - Fork 85
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
[ENG-6619] validate icon PNGs before running build #1477
Conversation
ENG-6619 Validate PNGs before running build
"INVALID_PNG_SIGNATURE" error seems like it may be caused by the user providing an invalid png file for their app icon or splash screen. For managed apps, we should be able to validate this before running their build, making this much less frustrating and we can provide a nice error at that point in the process. https://sentry.io/organizations/expoio/issues/3596287951/?project=1837720&query=is%3Aunresolved |
Size Change: +170 kB (0%) Total Size: 40.3 MB
|
if (!foregroundImage.endsWith('.png')) { | ||
Log.error(`The Android Adaptive Icon foreground image must be a PNG file.`); | ||
Log.error(`expo.android.adaptiveIcon.foregroundImage = ${chalk.bold(foregroundImage)}`); | ||
Errors.exit(1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are quickly checking the Android icon using endsWith
method. Do we want to do the same for the iOS icon?
0869fde
to
e94b3f7
Compare
4c18c69
to
3c2a1a7
Compare
Codecov Report
@@ Coverage Diff @@
## main #1477 +/- ##
==========================================
+ Coverage 51.16% 51.42% +0.26%
==========================================
Files 450 451 +1
Lines 15483 15584 +101
Branches 3041 3064 +23
==========================================
+ Hits 7921 8013 +92
- Misses 7549 7558 +9
Partials 13 13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
78ba92d
to
2141884
Compare
} | ||
|
||
async function validateAndroidIconAsync(ctx: CommonContext<Platform.ANDROID>): Promise<void> { | ||
if (!ctx.exp.android?.adaptiveIcon?.foregroundImage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the linear issue you linked is talking about the icon and splash screen, can you clarify why are you checking the adaptive icon foreground image(and why only that image)?
7287991
to
2141884
Compare
eb493d7
to
4bfc26a
Compare
4bfc26a
to
0f21407
Compare
This seems like a bug in Prebuild. The icon generation step should be converting the inputs into compliant outputs. Also icon fields can be URLs and a variety of other image formats which will now suddenly not work with EAS Build after this change lands. Potentially could be fixed here. Would be curious to learn more about why this is happening since we should be able to just automatically fix all images. |
Some follow up here for @byCedric / @EvanBacon on other CLI tooling:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's comment out iOS validation for now - I think it's possible that we'll revisit it in the future. otherwise looks good to ship
Can you elaborate? My code supports URLs. See https://github.com/expo/eas-cli/pull/1477/files#diff-e1c7866672b8c773c57f0c858398754872eebbf02a3ee3e8b238f45396efb312R72
I don't know anything about Prebuild. This PR is based on the Linear task description. Happy to see this fixed in Prebuild.
Sounds good!
What about transparency? |
0f21407
to
65da104
Compare
65da104
to
b3e7120
Compare
We handle removing transparency automatically in prebuild: https://github.com/expo/expo/blob/15d2337a623a7921f68d4e800cf10cf38c95f051/packages/%40expo/prebuild-config/src/plugins/icons/withIosIcons.ts#L130-L137 I tested this and it worked as expected. Where we may still encounter problems here is if people have bare apps where they set the icon manually and it has transparency |
@dsokal - one other suggestion - can we scope these validations to only projects that are using sdk 46 and lower? @EvanBacon has improved prebuild so it should be able to handle non-png icons and convert them to png. |
The feature looks good, but adding a gate to only apply on managed projects less than SDK 47 would be good. |
81ab748
to
6c23ff5
Compare
@brentvatne @EvanBacon can you please review the PR again? |
Checklist
/changelog-entry [breaking-change|new-feature|bug-fix|chore] [message]
and CHANGELOG.md will be updated automatically.Why
From https://linear.app/expo/issue/ENG-6619/validate-pngs-before-running-build:
How
For Android, validate the following app config fields:
For iOS:
plus check whether
exp.ios.icon ?? ctx.exp.icon
is not tranparent.Test Plan
Tests.