ReactiveNetwork icon indicating copy to clipboard operation
ReactiveNetwork copied to clipboard

Rare DeadSystemException when device (AndroidTV) goes to sleep

Open stari4ek opened this issue 6 years ago • 4 comments

Describe the bug I'm seeing rare crashes in Crashlytics with callstack:

java.lang.RuntimeException: android.os.DeadSystemException
	at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:797)
	at com.github.pwittchen.reactivenetwork.library.rx2.Connectivity.create(Connectivity.java:65)
	at com.github.pwittchen.reactivenetwork.library.rx2.Connectivity.create(Connectivity.java:50)
	at com.github.pwittchen.reactivenetwork.library.rx2.network.observing.strategy.MarshmallowNetworkObservingStrategy$5.onLost(MarshmallowNetworkObservingStrategy.java:165)
	at android.net.ConnectivityManager$CallbackHandler.handleMessage(ConnectivityManager.java:2845)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:154)
	at android.os.HandlerThread.run(HandlerThread.java:61)

Most probably device is going to sleep or power off. And there is network notification dispatched while VM is dying.

Expected behavior It would be nice to catch those errors and route with onError

Device:

  • Android: 7.0
  • Android Build: SVP4KDTV15_EU-user 7.0 NRD91N.S34 5.433 release-keys
  • Manufacturer: Sony
  • Model: BRAVIA 4K 2015
  • Thread: ConnectivityManager-797
implementation 'com.github.pwittchen:reactivenetwork-rx2:3.0.6'

stari4ek avatar Oct 21 '19 10:10 stari4ek

Hi @stari4ek,

Thanks for reporting this. According to the logs, it may be related to ConnectivityManager.getActiveNetworkInfo() method from Android API, which could throw DeadSystemException. I haven't seen that error before. Maybe catching this error while getting activeNetworkInfo will solve this problem. I'll have a look on that.

Regards, Piotr

pwittchen avatar Oct 21 '19 10:10 pwittchen

  • https://github.com/karczews/RxBroadcastReceiver/issues/13 And one more same of a kind:
Android: 8.0.0
Android Build: 31100 OTT1.180130.001
Manufacturer: SHARP
Model: AQUOS-4KTVX17
Thread: main-2

java.lang.RuntimeException: Unable to stop service by.stari4ek.iptv4atv.tvinput.service.IptvTvInputService@4b1810b: java.lang.RuntimeException: android.os.DeadSystemException
	at android.app.ActivityThread.handleStopService(ActivityThread.java:3587)
	at android.app.ActivityThread.-wrap26(ActivityThread.java:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
	at android.os.Handler.dispatchMessage(Handler.java:105)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6541)
	at java.lang.reflect.Method.invoke(Method.java)
	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.RuntimeException: android.os.DeadSystemException
	at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1438)
	at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:639)
	at com.github.karczews.rxbroadcastreceiver.RxBroadcastReceiver$ReceiverDisposable.dispose(RxBroadcastReceiver.java:71)
	at io.reactivex.internal.disposables.DisposableHelper.dispose(DisposableHelper.java:124)
	
        ... bunch of own Rx operators

	at by.stari4ek.iptv4atv.tvinput.service.IptvTvInputService.onDestroy(IptvTvInputService.java:37)
	at android.app.ActivityThread.handleStopService(ActivityThread.java:3569)

stari4ek avatar Oct 21 '19 10:10 stari4ek

Error from the last log looks like it's caused by another library, but general problem is probably the same.

pwittchen avatar Oct 21 '19 10:10 pwittchen

ah. ouch. you're right. Sorry for that

stari4ek avatar Oct 21 '19 11:10 stari4ek