BranchMetrics / sdk-release

TUNE iOS, Android, and Windows native SDKs
https://developers.tune.com/sdk/quick-starts/
GNU General Public License v3.0
56 stars 46 forks source link

SDK 4.10.0: java.lang.IllegalStateException: Timer was canceled #32

Open gsams04 opened 7 years ago

gsams04 commented 7 years ago

Hi,

We recently upgraded to 4.10.0 from 4.4.0 and we've received multiple reports of this crash

java.lang.IllegalStateException: Timer was canceled
    at java.util.Timer.scheduleImpl(Timer.java:558)
    at java.util.Timer.schedule(Timer.java:456)
    at com.tune.location.TuneLocationListener$GetLocationUpdates.run(TuneLocationListener.java:249)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:211)
    at android.app.ActivityThread.main(ActivityThread.java:5317)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

We haven't personally seen this issue but this happens in all OS versions starting Lollipop.

If it's of any help, here's how we initialize Tune.

Tune.init(app,tune_advertiser_id,tune_converion_key );
Tune.getInstance().setShouldAutoCollectDeviceLocation(false);

What could've possibly been the problem?

Thanks for the help.

john-gu commented 7 years ago

Hi @gsams04, it looks like a timing issue when the timer is canceled by setShouldAutoCollectDeviceLocation soon after init.

A better way to disabling location collection is to use the TuneConfiguration option in init:

TuneConfiguration tuneConfig = new TuneConfiguration();
tuneConfig.setShouldAutoCollectDeviceLocation(false);

Tune.init(this, "your_advertiser_id", "your_conversion_key", false, tuneConfig);

I will create a ticket to make setShouldAutoCollectDeviceLocation more thread-safe.