-
Notifications
You must be signed in to change notification settings - Fork 371
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
WorkManager is not initialized properly #1672
Comments
One internal report:
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="{myApplicationId}.androidx-startup"
android:exported="false" >
<meta-data
android:name="androidx.lifecycle.ProcessLifecycleInitializer"
android:value="androidx.startup" />
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup" />
</provider>
<provider
android:name="{some.library}.SomeProvider"
android:authorities="{myApplicationId}.SomeProvider"
android:exported="false"
android:initOrder="99" />
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="{myApplicationId}.firebaseinitprovider"
android:directBootAware="true"
android:exported="false"
android:initOrder="100" />
<provider
android:name="{some.library}.SomeProvider"
android:authorities="{myApplicationId}.SomeProvider"
android:exported="false" />
<provider
android:name="{some.library}.SomeProvider"
android:authorities="{myApplicationId}.SomeProvider"
android:exported="false"
android:grantUriPermissions="true"
android:initOrder="101" />
<provider
android:name="com.google.android.gms.ads.MobileAdsInitProvider"
android:authorities="{myApplicationId}.mobileadsinitprovider"
android:exported="false"
android:initOrder="100" />
<provider
android:name="{some.library}.SomeProvider"
android:authorities="{myApplicationId}.SomeProvider"
android:exported="false"
android:grantUriPermissions="true" />
<provider
android:name="{some.library}.SomeProvider"
android:authorities="{myApplicationId}.SomeProvider" />
Reported for Samsung and Hawei. Unsure of more specifics (unreported to us).
|
|
@toseefhaiderkhansugguu Thanks for reporting, however on item 2 I noticed you don't have the
|
Another thing that stands out is that you can reproduce this crash, which is a big step forward because we have not heard reports of successful reproduction.
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="{myApplicationId}.androidx-startup"
android:exported="false" >
<meta-data
android:name="androidx.lifecycle.ProcessLifecycleInitializer"
android:value="androidx.startup" />
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup" />
</provider>
...
<provider
android:name="{some.library}.SomeProvider"
android:authorities="{myApplicationId}.SomeProvider"
android:exported="false"
android:initOrder="99" />
...
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="{myApplicationId}.firebaseinitprovider"
android:directBootAware="true"
android:exported="false"
android:initOrder="100" />
...
<provider
android:name="com.google.android.gms.ads.MobileAdsInitProvider"
android:authorities="{myApplicationId}.mobileadsinitprovider"
android:exported="false"
android:initOrder="100" />
|
I implemented the below code as Google's guide to fix this issue temporally on our side. But unfortunately this issue has not resolved yet. And the worse part of this crash is that it usually occur on main activity's onResume cycle, so it kills my app whenever users return from other activities like as Ad viewer, etc. Is there anyone who resolves this issue with the below fix?
And here's answers for questions.
androidx.work:work-runtime 2.7.0 most version of Android (5~12) 200 crashes per day on Google Play Console. It's almost a half of all crashes we're getting.
com.onesignal:OneSignal 4.8.3 No, I can't. After I updated onesignal SDK version from 3.16.2 to 4.8.3 |
@mhchoi-bagelcode Thanks for reporting, and trying the workaround, it would seems this doesn't fix the root issue then based on your testing. Possible issueCan you check the logcat on your own devices to see if you have any
The only theory we have is that other providers could be failing to load causing the other providers to never run. This is only a theory but there seems to be some relation so far. It is important to fix all Lastly are you able to reproduce the crash in any scenarios on your own devices? |
@jkasten2
|
@mhchoi-bagelcode Thanks for the I agree that setting a higher |
@jkasten2 Unfortunately, This crash has not been resolved, even if I injected the initOrder tag to our Manifest.xml
I don't know what to do for next step. |
@mhchoi-bagelcode There is possible fix that has worked for two others:
<application
android:label="@string/android_app_name"
android:icon="@drawable/Icon"
android:largeHeap="true"
android:hardwareAccelerated="false"
android:allowBackup="false"
android:fullBackupContent="false"
tools:node="replace"
tools:ignore="GoogleAppIndexingWarning"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/facebook_app_name" />
Source: #1561 (comment) I would also recommend adding details to this Google thread to bring the issue to their attention: From what we have found so far this WorkManger issue doesn't seem to be an issue the way OneSignal is using WorkManager. The bug is present in app's that don't use OneSignal too, so we are trying to get Google to invest in helping find the root cause as well. |
There is a new last message (Jan 3, 2023 08:31PM) in the Google thread https://issuetracker.google.com/issues/258176803 |
This solution is not fit to our project (no tools:node="replace" attrubute already), so I couldn't try it. |
We saw the response from the Google representative, but they may not completely understand how They are correct if OneSignal is initialized in a Content Provider, but it is not. The default Work Manger should be initialized by We can still try the speculative fix to initialize Work Manager ourselves if it is However, maybe it doesn't run into that second crash and this crash would be fixed. |
* Provides a way to check if WorkManager is initialized in this process. * This is effectively the `WorkManager.isInitialized()` public method introduced in `androidx.work:work-*:2.8.0-alpha02`. * Please see https://android-review.googlesource.com/c/platform/frameworks/support/+/1941186 for the library's implementation * Please see issue this aims to address: #1672
* Before using WorkManager, check for its existence. Else, initialize it ourselves. * Please see issue: #1672
* Before using WorkManager, check for its existence. Else, in rare cases that were crashing, initialize it ourselves. * Provides a method to check if WorkManager is initialized in this process. * This is effectively the `WorkManager.isInitialized()` public method introduced in `androidx.work:work-*:2.8.0-alpha02`. * Please see https://android-review.googlesource.com/c/platform/frameworks/support/+/1941186 for the library's implementation * Please see issue this aims to address: #1672
* Before using WorkManager, check for its existence. Else, in rare cases that were crashing, initialize it ourselves. * Provides a method to check if WorkManager is initialized in this process. * This is effectively the `WorkManager.isInitialized()` public method introduced in `androidx.work:work-*:2.8.0-alpha02`. * Please see https://android-review.googlesource.com/c/platform/frameworks/support/+/1941186 for the library's implementation * Please see issue this aims to address: #1672
* Before using WorkManager, check for its existence. Else, in rare cases that were crashing, initialize it ourselves. * Provides a method to check if WorkManager is initialized in this process. - This is effectively the `WorkManager.isInitialized()` public method introduced in `androidx.work:work-*:2.8.0-alpha02`. - Please see https://android-review.googlesource.com/c/platform/frameworks/support/+/1941186 for the library's implementation * Please see issue this aims to address: #1672
* Before using WorkManager, check for its existence. Else, in rare cases that were crashing, initialize it ourselves. * Provides a method to check if WorkManager is initialized in this process. - This is effectively the `WorkManager.isInitialized()` public method introduced in `androidx.work:work-*:2.8.0-alpha02`. - Please see https://android-review.googlesource.com/c/platform/frameworks/support/+/1941186 for the library's implementation * Please see issue this aims to address: #1672
hey @nan-li , Have you tried to add Multiprocess support dependency?
|
Hey @hayk888997, Good suggestion. Multiprocess support dependency is something that end users of OneSignal can add to their own Android Manifest if their app uses multiprocess. This rare crash we are seeing seems unrelated to having multiprocess apps as we have numerous reports of it on apps that do not use multiprocess. |
Anyone who is having this issue please update to OneSignal-Android-SDK 4.8.5 as this should address this issue. Please report back if updating to this version fixes the issue for you or if you continue to see these same crashes. |
issue still persists, it happens after the App update. I cannot reproduce it on the emulator. got the data from Crashlytics. Using 4.8.6 I run dependency initialization multithreaded. Looking at your code, it might be possible that workmanager initialization happens during the small gap on checking workmanager instance is present or not, and request to initialize the workmanager from OSWorkManagerHelper. (Speculative) |
Hi @willyric17, Thank you for reporting this update, and I apologize for the delay in responding. The Can you tell me if you experienced any WorkManager issues with OneSignal on your previous version? Did you ever have Can you tell me how often |
Hi all, we made updates to Work Manager in Release 5.1.15 for the User Model SDK and Release 4.8.10 for the Player Model SDK. |
Need update for version 3.x.x |
Yes, we will release updates for the cross-platform SDKs. |
Yes, sorry I mean new version for Unity. |
@shefich This update is now included in the OneSignal-Unity-SDK 5.1.7 release. |
@jkasten2 what about version 3.x.x? |
Description
We have seen many reported crashes related to this particular WorkManager IllegalStateException:
However, the OneSignal SDK uses the default
WorkManagerInitializer
and does not disable it. We are collecting information to investigate any solutions on our end as well as make a report of this to Google, as this seems to be related to an AndroidX library that OneSignal uses. For reference, these are reports of this and related exceptions to Google's Issue Tracker.Current status
Google Issue Tracker
We reported this to Google's WorkManager issues here.
Summary
From reported stacktraces, the crash arises from
OSNotificationRestoreWorkManager.beginEnqueueingWork()
,OSFocusHandler.cancelOnLostFocusWorker()
, andOSFocusHandler.startOnLostFocusWorker()
.We know this can be related to multiprocess, but we have also seen many reports of this exception in applications that don't use multiprocess.
This is happening on applications that don't use WorkManager themselves and don't use Custom WorkManager Configuration and Initialization.
OneSignal maintainers have not been able to reproduce this crash, and users have not reported being able to reproduce this crash either. While there have been reports of some apps encountering this crash 100% of the time, those cases are related to other underlying issues.
This crash is also happening across multiple versions of
androidx.work:work-runtime
including on the latest stable release2.7.1
. It also appears to affect devices across types, brands, and Android versions.We speculate it may have to do with the initialization of libraries and components during an app's startup process, and encountering edge cases where OneSignal tries to access the
WorkManager
singleton but it has not yet been initialized by the system. This crash happens when the OneSignal SDK callsWorkManager.getInstance(Context)
and theWorkManager
isnull
.Also from Android docs, content providers are created on the application main thread at application launch time and Android initializes content providers in an undetermined order. If there are many providers to initialize, the one that contains the
WorkManagerInitializer
may not get created until later in the process, making the edge case more likely. In addition, if other<providers>
s in the Manifest haveinitOrder
set, those will initialize first.Details Appreciated
To investigate further and gather insight into this crash's relationship to the app startup process, please tell us as much of the following information as possible.
Confirm that you are not using custom WorkManagerInitializer yourself.
Please look in the Merged Manifest for all the
<provider>
tags you have. Please provide the exact content of all of them. This information is informative as we speculate that having more ContentProviders may cause this crash to happen more often. Providing the full information helps us know which ones are involved. Here is an example:Look in the Merged Manifest or run
./gradlew app:dependencies
to tell us the version ofandroidx.work:work-runtime
your app is using.Analytics of this crash: What devices and Android versions are experiencing the crash? Are there some devices or Android versions that are affected more?
Analytics of this crash: How many users and what percent of your users experienced this crash?
The stacktrace for this crash.
The version of the
OneSignal-Android-SDK
your app is using.Are you able to reproduce this crash yourself?
Do you have information about when you started seeing this crash, what changes were made?
Possible Fix on the SDK User's End
Implement a custom WorkManagerInitializer for your app by following the On-Demand Initialization guide. Make sure to complete both steps for "Remove the default initializer" and "Implement Configuration.Provider".
This crash happens when the OneSignal SDK calls
WorkManager.getInstance(Context)
when theWorkManager
singleton has not yet been initialized by the system, and the method will produce this exception. However, if an app implemented customWorkManagerInitializer
, this method will instead initialize theWorkManager
singleton when it isnull
.If you do this, please report back your results.
The text was updated successfully, but these errors were encountered: