-
Notifications
You must be signed in to change notification settings - Fork 369
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
[Bug]: Version 4.8.5 breaks Hilt dependency injection of CoroutineWorker
s
#1748
Comments
Hi @sebastinto, I am so sorry for the delayed response and thank you for the detailed post. We made a speculative fix for a We will investigate the Android source code for Hilt and the Work module to see what may be happening, and perhaps be able to reproduce some part of this ourselves, such as the factory being Can you answer some questions to help me understand what is happening?
|
I did skim through this fix since I thought might be the source of the crash but couldn't see anything obvious either. If it is what's causing the issue I'd be curious to know how so please keep us posted.
Not that I know of.
100%
It was actually caught during QA before sending to prod (on a Google Play Store internal testing track) and I'm able to reproduce myself on release variants signed with a debug certificate. |
Hi @sebastinto, thank you for the information. I have some followup asks:
You can also email the project and/or stack traces to support@onesignal.com and reference this GitHub issue, if it is easier to send that way. Thank you so much |
|
Hi @sebastinto
|
Here's a sample project for your consideration: https://github.com/sebastinto/OneSignalSampleProject It is a pretty accurate reduced-complexity representation of the project where the issue occurred. Unfortunately, I could not reproduce the exact same error BUT another error follows the same pattern of occurring with version I've added todo comments to the project to guide testing but here are some detailed steps:
Look at the logcat to verify that
Then:
Both workers should succeed. As an additional troubleshooting step, since the field injection of Don't hesitate to follow-up with additional questions / clarifications, thanks! |
Hi @sebastinto, An update that I am able to run your project and receive the same error of Nothing else of substance to update at this time. |
Thanks for the update @nan-li ! |
Is there any fix incoming for this issue? I recently had to drop our OneSignal version from |
ANR with 4.8.4 too:
|
Hi, is this issue is fixed in the latest version? |
fixed? |
@rvenky125 I haven't experienced this particular issue on v5 so migrating will probably the way to solve it. Unfortunately be advised that for our use case, #1854 and #1969 prevent us from migrating ATM but YMMV. |
me too submit my code
Error Log
|
@nan-li To support Hilt injection in Workers we have to provide WorkManger with a custom configuration. To do that our Application class implements Configuration.Provider so that WorkManager could get the custom configuration having the application context. But OneSignal SDK breaks this and passes a default configuration to WorkManager ignoring our custom configuration. Here is the documentation about the custom configuration: https://developer.android.com/develop/background-work/background-tasks/persistent/configuration/custom-configuration |
Hi @lemeshkevich, thanks for your post, it makes sense to me. The goal with initializing WorkManager ourselves is if we detect there is not one and we are about to use it (we have seen this in rare crashes when it should be available). However, it may be that how Hilt works, it does not make the WorkManager instance available at the time we check but supplies it when it is called. I will take a look at this issue again. |
I started getting a similar but different bug in OneSignal 5.1.14. I read through the explanations here and in this issue tracker thread. Different stack trace, but this is related to OneSignal instantiating a WorkManager instance without reading the application's I'm really not sure why they didn't bother to even attempt to read the application's configuration in #2052 instead of just using an empty, default configuration. Stacktrace:
This workaround feels really stupid, but I was able to get around this issue by simply getting an instance of WorkManager in my application's
I was able to RGR test this just now. For anyone else running into this issue (or something similar like mine), maybe try this? This should ensure that WorkManager is available with the correct configuration before OneSignal calls it. |
@isles1217 , this issue came up for us yesterday morning. It's kind of crazy that you posted a workaround just hours later. Thanks for this. It's solving our problem temporarily until OneSignal makes a fix. |
Hi all, we made updates to Work Manager in several release, the latest of which are: Release 5.1.15 for the User Model SDK and Release 4.8.10 for the Player Model SDK. Thanks for your help in resolving this. |
What happened?
I've recently started experiencing
java.lang.NoSuchMethodException
when buildingCoroutineWorker
classes.The issue disappears when specifying version
4.8.4
of the OneSignal Android SDK inlibs.version.toml
. So instead of declaring the dependency asonesignal = "[4.0.0, 4.99.99]"
, declaring it asonesignal = "4.8.4"
.Only release builds seem to be affected. Debug builds or release builds with the
isDebuggable
property set totrue
in the app-levelbuild.gradle.kts
work fine with the latest version of the SDK.Maybe more relevant for #1672, but adding a breakpoint at line 55 of
HiltWorkerFactory
seems to indicate that when Hilt attempts to instantiatecom.onesignal.OSNotificationRestoreWorkManager$NotificationRestoreWorker
orcom.onesignal.OSFocusHandler$OnLostFocusWorker
, the factory isnull
. When using the app'sCoroutineWorker
s the breakpoint is not hit.I'm using
work = "2.8.0"
andhilt = "2.45"
My app class:
I have this in my AndroidManifest.xml file:
Example of how I declare and enqueue one of the
CoroutineWorker
s that fail (although I don't think this is relevant)workManager
is injected here:Steps to reproduce?
What did you expect to happen?
I expected OneSignal to not interfere with CoroutineWorkers outside of its library 😬
OneSignal Android SDK version
Release 4.8.5
Android version
13, 10
Specific Android models
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: