WiFiFlutter icon indicating copy to clipboard operation
WiFiFlutter copied to clipboard

[wifi_iot] Crash at WifiManager.getScanResults

Open DarkDancers opened this issue 3 years ago • 3 comments

Hi WiFiFlutter Team, We found multiple crashes on firebase. Please check the Stack Trace as following:

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.net.wifi.WifiManager.getScanResults()' on a null object reference
       at com.alternadom.wifiiot.WifiIotPlugin.handleNetworkScanResult(WifiIotPlugin.java:649)
       at com.alternadom.wifiiot.WifiIotPlugin$4.onReceive(WifiIotPlugin.java:643)
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1573)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(-.java:2)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7438)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:989)

DarkDancers avatar Apr 08 '22 06:04 DarkDancers

Ok, looks like the Flutter engine was detached and attached back - in between the scan event received might have caused this crash. Is it a one time crash? or happening in specific conditions? are you able to reproduce it?

daadu avatar Apr 08 '22 07:04 daadu

just discovered this crash. still look into it not able to reproduce atm. from firebase report: 20933 crash events affecting 8104 users seem its not one time crash

Ok, looks like the Flutter engine was detached and attached back - in between the scan event received might have caused this crash. Is it a one time crash? or happening in specific conditions? are you able to reproduce it?

DarkDancers avatar Apr 08 '22 07:04 DarkDancers

Seems like a tricky bug, let me know if you find more info.

I have following ideas:

  1. not resetting "context" and "wifiManger" in cleanup
  2. unregister Broadcast receiver in cleanup
  3. always get WiFiManger "in-line" instead of getting-and-caching instance in "init"

Check the code if you can get some hint, what is wrong.

daadu avatar Apr 08 '22 08:04 daadu