Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Focus nightly crashes on startup with FLAG_IMMUTABLE or FLAG_MUTABLE in PendingIntent #6244

Closed
jonalmeida opened this issue Jan 18, 2022 · 9 comments

Comments

@jonalmeida
Copy link
Contributor

jonalmeida commented Jan 18, 2022

Focus Nightly after #6223 landed crash on startup.

I and others were only able to reproduce this crash from installing the app through GPS. Building locally with debug or release didn't see to trigger the crash. See conversation on Matrix.

Related AC: mozilla-mobile/android-components#11563

2022-01-18 01:04:09.380 7229-7229/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.mozilla.focus.nightly, PID: 7229
    java.lang.RuntimeException: Unable to create application org.mozilla.focus.FocusApplication: java.lang.IllegalArgumentException: org.mozilla.focus.nightly: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6733)
        at android.app.ActivityThread.access$1500(ActivityThread.java:247)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2057)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
     Caused by: java.lang.IllegalArgumentException: org.mozilla.focus.nightly: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
        at android.app.PendingIntent.getActivity(PendingIntent.java:444)
        at android.app.PendingIntent.getActivity(PendingIntent.java:408)
        at org.mozilla.focus.Components$crashReporter$2.invoke(Components.kt:19)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:5)
        at org.mozilla.focus.Components.getCrashReporter(Components.kt:1)
        at org.mozilla.focus.FocusApplication.onCreate(FocusApplication.kt:6)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6728)
        	... 9 more
@ionutbedregeanu ionutbedregeanu self-assigned this Jan 18, 2022
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 18, 2022
Since Android 12 we need to set PendingIntent mutability explicitly
This additional requirement improves your app's security.
All pending intents are updated to contain also the flag FLAG_IMMUTABLE when the version of
Android SDK is bigger than 30
FLAG_IMMUTABLE -> Flag indicating that the created PendingIntent should be immutable.
@Mugurell
Copy link
Contributor

Paired with Ionut on this, seems like even after setting the right flags in Focus the app will still crash because of an older version of androidx.work:work-runtime - 2.4.0 used in many AC components.
We could force a newer version in build.gradle but seems like AC needs to be updated also for a proper fix.

Seems like Fenix will also crash in these conditions once being set to target 31 so AC needs to be updated before that.

ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 18, 2022
Since Android 12 we need to set PendingIntent mutability explicitly, but Android 6 can be the
minimum version
This additional requirement improves your app's security.
All pending intents are updated to contain also the flag FLAG_IMMUTABLE when the version of
Android SDK is bigger than 30
FLAG_IMMUTABLE -> Flag indicating that the created PendingIntent should be immutable.
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 18, 2022
…sion

At this moment WorkManager 2.4.0 doesn't have support for Android 12 so we are
constrained to force import a newer version(2.7.0)
This is a temporary solution until the version of WorkManager will be updated from AC
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 18, 2022
Since Android 12 we need to set PendingIntent mutability explicitly, but Android 6 can be the
minimum version
This additional requirement improves your app's security.
All pending intents are updated to contain also the flag FLAG_IMMUTABLE when the version of
Android SDK is bigger than 30
FLAG_IMMUTABLE -> Flag indicating that the created PendingIntent should be immutable.
Entire IntentUtils code was unused so it was removed
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 18, 2022
…sion

At this moment WorkManager 2.4.0 doesn't have support for Android 12 so we are
constrained to force import a newer version(2.7.0)
This is a temporary solution until the version of WorkManager will be updated from AC
@Amejia481
Copy link
Contributor

Paired with Ionut on this, seems like even after setting the right flags in Focus the app will still crash because of an older version of androidx.work:work-runtime - 2.4.0 used in many AC components. We could force a newer version in build.gradle but seems like AC needs to be updated also for a proper fix.

Seems like Fenix will also crash in these conditions once being set to target 31 so AC needs to be updated before that.

Then, I think we should update version AC too

@jonalmeida
Copy link
Contributor Author

Then, I think we should update version AC too

For context, this was originally backed out. See: mozilla-mobile/android-components#11541

@Mugurell
Copy link
Contributor

Mugurell commented Jan 19, 2022

Then, I think we should update version AC too

For context, this was originally backed out. See: mozilla-mobile/android-components#11541

"Circular dependency hell" 🤣
Then it seems like we should force 2.8.0 here since we're already targetting Android 31 (hopefully there won't be any bugs because of incompatibilities with other androidx libs).
And then for Fenix targetting Android 31 and using a newer version of WM in AC should happen ~at the same time. After which Focus will also switch to again allow and use any transitive WM.

ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 19, 2022
Since Android 12 we need to set PendingIntent mutability explicitly, but Android 6 can be the
minimum version
This additional requirement improves your app's security.
All pending intents are updated to contain also the flag FLAG_IMMUTABLE when the version of
Android SDK is bigger than 30
FLAG_IMMUTABLE -> Flag indicating that the created PendingIntent should be immutable.
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 19, 2022
…sion

At this moment WorkManager 2.4.0 doesn't have support for Android 12 so we are
constrained to force import a newer version(2.7.0)
This is a temporary solution until the version of WorkManager will be updated from AC
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 19, 2022
Since Android 12 we need to set PendingIntent mutability explicitly, but Android 6 can be the
minimum version
This additional requirement improves your app's security.
All pending intents are updated to contain also the flag FLAG_IMMUTABLE when the version of
Android SDK is bigger than 30
FLAG_IMMUTABLE -> Flag indicating that the created PendingIntent should be immutable.
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 19, 2022
…sion

At this moment WorkManager 2.4.0 doesn't have support for Android 12 so we are
constrained to force import a newer version(2.7.0)
This is a temporary solution until the version of WorkManager will be updated from AC
@Amejia481
Copy link
Contributor

Then, I think we should update version AC too

For context, this was originally backed out. See: mozilla-mobile/android-components#11541

"Circular dependency hell" 🤣 Then it seems like we should force 2.8.0 here since we're already targetting Android 31 (hopefully there won't be any bugs because of incompatibilities with other androidx libs). And then for Fenix targetting Android 31 and using a newer version of WM in AC should happen ~at the same time. After which Focus will also switch to again allow and use any transitive WM.

😆
I guess we could temporary force the WM version until we get the updated one in AC and then we could remove the temporary fix :)

@jonalmeida
Copy link
Contributor Author

I think we can put the WM upgrade back in now that we have Focus on 31. I'll put up a PR for that and try it out in Focus.

ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 20, 2022
Since Android 12 we need to set PendingIntent mutability explicitly, but Android 6 can be the
minimum version
This additional requirement improves your app's security.
All pending intents are updated to contain also the flag FLAG_IMMUTABLE when the version of
Android SDK is bigger than 30
FLAG_IMMUTABLE -> Flag indicating that the created PendingIntent should be immutable.
ionutbedregeanu pushed a commit to ionutbedregeanu/focus-android that referenced this issue Jan 20, 2022
…sion

At this moment WorkManager 2.4.0 doesn't have support for Android 12 so we are
constrained to force import a newer version(2.7.0)
This is a temporary solution until the version of WorkManager will be updated from AC
mergify bot pushed a commit that referenced this issue Jan 20, 2022
Since Android 12 we need to set PendingIntent mutability explicitly, but Android 6 can be the
minimum version
This additional requirement improves your app's security.
All pending intents are updated to contain also the flag FLAG_IMMUTABLE when the version of
Android SDK is bigger than 30
FLAG_IMMUTABLE -> Flag indicating that the created PendingIntent should be immutable.
mergify bot pushed a commit that referenced this issue Jan 20, 2022
At this moment WorkManager 2.4.0 doesn't have support for Android 12 so we are
constrained to force import a newer version(2.7.0)
This is a temporary solution until the version of WorkManager will be updated from AC
@softvision-oana-arbuzov

Also reproducible with Firefox Focus Nightly 98.0 (🦎 98.0a1-20220119093435) on Google Pixel 5 (Android 12).

Note: Not reproducible on Samsung Galaxy S8 (Android 9) with the same build.

@jonalmeida jonalmeida added the QAReady flag for test read & needed label Jan 20, 2022
@delia-pop
Copy link

Tested on Firefox Focus Nightly 98.0 (Build 360310515 🦎 98.0a1-20220130093554) with Google Pixel 6 (Android 12).
The application no longer crashes on launch.

@delia-pop delia-pop added QAVerified and removed QAReady flag for test read & needed labels Jan 31, 2022
@softvision-oana-arbuzov
Copy link

I can confirm it works for me too now, I was able to load Firefox Focus Nightly.
image

Tested with:
Browser / Version: Firefox Focus Nightly 98.0 (🦎 98.0a1-20220201093942)
Operating System: Google Pixel 5 (Android 12) - 1080 x 2340 pixels, 19.5:9 ratio (~432 ppi density)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants