Skip to content
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

fix(android): Resolve a crash under Android 7 #5206

Merged
merged 1 commit into from
Apr 23, 2021

Conversation

ifsnow
Copy link
Contributor

@ifsnow ifsnow commented Apr 23, 2021

Description

Related to : #4981

TaskExecutorService is using API level 24 Collection functions such as removeIf, forEach.
This can cause build failure or crash under Android 7.

I'm sure it needs to be modified to work with the lower minSdkVersion.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

None

@vercel
Copy link

vercel bot commented Apr 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/invertase/react-native-firebase/Gfz89ZQ3GXwFkHPAnb4BHGybJpKa
✅ Preview: https://react-native-f-git-fork-ifsnow-fix-crash-task-executor-s-a709a9.vercel.app

@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #5206 (12c80a4) into master (e772957) will increase coverage by 3.61%.
The diff coverage is n/a.

❗ Current head 12c80a4 differs from pull request most recent head 6b7afe5. Consider uploading reports for the commit 6b7afe5 to get more accurate results

@@            Coverage Diff             @@
##           master    #5206      +/-   ##
==========================================
+ Coverage   85.26%   88.87%   +3.61%     
==========================================
  Files         109      109              
  Lines        3744     3744              
  Branches      360      360              
==========================================
+ Hits         3192     3327     +135     
+ Misses        481      370     -111     
+ Partials       71       47      -24     

@mikehardy
Copy link
Collaborator

Oh my! Thank you for letting us know, this is a new feature and is a great performance enhancement - when it's working - but we have no intention of requiring minSdkVersion 24 - I'll check into this and sorry for the bother. The releases prior to this (11.2.x) have no problems with them, it should be fine to revert until we've fixed

@mikehardy
Copy link
Collaborator

Having tried this in another project I will likely go another direction, it has worked well for us:

https://github.com/ankidroid/Anki-Android/pull/8361/files

https://developer.android.com/studio/write/java8-support-table

  • removeIf is supported
  • forEach is supported

It has not appreciably increased build times either

A related failure (obviously) is that this was not caught and stopped in our CI, I'll alter our CI to use our minSdkVersion for the Android emulator (or the min possible - not sure 16 is still a reliable emulator, but something under 24 is, 21 at least I know works) vs the version it is on now

@ifsnow
Copy link
Contributor Author

ifsnow commented Apr 23, 2021

@mikehardy I don't think it's the best way to support just 2 functions.

That's because using desugaring increases the App file size by 120kb. (APK file - release build)

If it is not necessary for the whole project and is not used frequently, you need to consider whether it is necessary to use it.

It's just my opinion.

@mikehardy
Copy link
Collaborator

@ifsnow that's a reasonable point, I understand the internal storage constraints of a lot of devices and am sensitive to that, plus we're a library not an app so we would be effectively making this decision (programming clarity vs apk size) for all consumers vs leaving it to them.

Your code looks correct on first review and I'll look into the CI failure on the PR (likely unrelated), and merge it as is if it passes though. I want to alter our CI to reproduce the failure first though (API21 is available for testing in CI, as an emulator) so this can't happen again. Errors like this should never get past CI.

@mikehardy
Copy link
Collaborator

Still working through CI flakiness so I can't merge this just yet, and I'll be traveling next 5hrs so this will likely be merged released overnight your time. Just giving you the update since it's nearly end of day there and this is a pretty serious issue. It'll be fixed by your next day though, thanks again for reporting this and posting the fix, I really appreciate it.

@mikehardy mikehardy merged commit 49c15f8 into invertase:master Apr 23, 2021
mikehardy added a commit that referenced this pull request Apr 24, 2021
Java lint was not being checked anywhere, and the NewApi check in particular
would have stopped a crash. Add full lint configuration tuned for current status

Cannot enable it on the modules or our modules may fail library-consumer's builds,
but we may configure it on the sub-modules from our test app then check that

Tested and working and would have correctly failed the NewApi violation shown in #5206
mikehardy added a commit that referenced this pull request Apr 24, 2021
Java lint was not being checked anywhere, and the NewApi check in particular
would have stopped a crash. Add full lint configuration tuned for current status

Cannot enable it on the modules or our modules may fail library-consumer's builds,
but we may configure it on the sub-modules from our test app then check that

Tested and working and would have correctly failed the NewApi violation shown in #5206
@mikehardy
Copy link
Collaborator

v11.3.3 just went out with this fix, and I merged a CI change that will make sure it never happens again!

androidIsForVivek pushed a commit to androidIsForVivek/react-native-firebase that referenced this pull request Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants