-
Notifications
You must be signed in to change notification settings - Fork 64
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
Snowplow.createTracker takes 10 seconds? #620
Comments
Also on Android 9, Samsung Note |
Hi @peterdk, that is very unexpected, could you please help me replicate this? I have created a blank new Android app and pasted in the code that you provided above, see here.
Could you please tell me what is different about your setup or help me extend the app to replicate the problem? |
Yeah, I just moved the code to onCreate, like in the docs, and there it runs indeed very fast. |
I don't think running on a background thread should be the problem - I have just tried it and the call was instant as well. |
I debugged, and we indeed load our analytics module and thus also Snowplow, on a background coroutine dispatcher/thread.
What I see is that with this sleep of the main thread, the createTracker only returns after the main thread is done. Without it it returns indeed in a few 100ms. So I guess SnowPlow needs the main thread somewhere in its initialisation code and has to wait until that thread is available, before being able to return the tracker. Ofcourse we don't sleep on the main thread, but it is busy for a long time. |
Probably can be reproduced without coroutines, since we don't use anything here that is coroutine related. |
Interesting! I can't think of anything in the tracker that would require running on the main thread, but will look into this! |
Yes, with:
I have the same result. (Method is just calling the proper Snowplow setup in it) |
I think I am still missing something here, because when I tried to do this in the example app, see here, the
|
I'll try to look in a working example there. |
I can't reproduce it indeed in the test project. Also not when I move it tot an Application class. I'll look into it next week to see if I can reproduce it, otherwise we'll work around it. |
We're experiencing the same issue here. Hard to say why yet, but can you point us to where is the offloading from the main thread done in order to retrieve the @peterdk do you have any pointer on how did you solve this ? |
Hi @dpgmedia-gbero, there are two ways that the
Since version 6 of the trackers, there is now an option to override how the tracker retrieves the IDFA and provide a custom retriever function – see the docs here. Maybe it would be worth overriding this to see if it solves the problem? |
Hi @matus-tomlein thanks for your reply. I could reproduce the issue in your setup by adding gms ads dependency, see here |
The 10-second duration is actually caused by :
|
I did not yet find a proper solution for this as well. I can initialize in onCreate(), but that makes my co-devs not very happy, since we just want to do this in Koin. I tried the 6.0.1 version, and then fetch the Idfa myself earlier in the init method, but that also caused the same blocking. Hopefully the repro from gbero can lead to a working fix. For now we temporarily disable idfa by returning null from PlatformContextReceiver androidIdfa method. |
Thanks @dpgmedia-gbero, that is super useful to be able to reproduce! We will look into this and aim for a patch release with a fix. The solution might actually be pretty simple – add this kind of condition to check that we are not on the main thread in the |
Describe the bug
When initiating Snowplow it takes 10 seconds to complete that call.....
To Reproduce
val network = NetworkConfiguration(endpoint = "url", HttpMethod.POST)
val config = TrackerConfiguration(context.packageName).screenViewAutotracking(true)
Snowplow.createTracker(
context = context,
namespace = "namespace",
network = network,
config,
)
Expected behavior
200ms setup time or something reasonable.
Device information (please complete the following information):
Additional context
Not useable this way
The text was updated successfully, but these errors were encountered: