home_widget icon indicating copy to clipboard operation
home_widget copied to clipboard

FLutter engine initialisation before callback lookup?

Open roly151 opened this issue 2 years ago • 2 comments

Hi, I have had two recent crashes with the following:

java.lang.UnsatisfiedLinkError: 
  at io.flutter.embedding.engine.FlutterJNI.nativeLookupCallbackInformation (Native Method)
  at io.flutter.view.FlutterCallbackInformation.lookupCallbackInformation (Unknown Source)
  at es.antonborri.home_widget.HomeWidgetBackgroundService.onCreate (HomeWidgetBackgroundService.java:42)
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4641)
  at android.app.ActivityThread.access$2800 (ActivityThread.java:251)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2319)
  at android.os.Handler.dispatchMessage (Handler.java:110)
  at android.os.Looper.loop (Looper.java:219)
  at android.app.ActivityThread.main (ActivityThread.java:8393)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1055)

I'm only a beginner, but a search found this link:

https://github.com/flutter/flutter/issues/69250

One of the solutions said:

I've just got the same issue. Fixed it by moving FlutterEngine initialization to before callback lookup. Please see here for reference. https://github.com/flutter/plugins/commit/de56da50ca78ef275a95b4e59ce8d5e119eadd7a#diff-e57a1a7ffb729ad174b597626202429c1c87e4168e19b2aa9decc1be84e8777b

Not sure if this is something I need to do, or it's within home_widget? Hopefully you can provide some guidance.

roly151 avatar Mar 06 '22 22:03 roly151

Sorry for only getting back to this now. Do you have a somewhat reproducible way of causing this crash?

I guess the lines https://github.com/ABausG/home_widget/blob/a919d08852dfdd4e82e63a518b6c91f3008e1c03/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetBackgroundService.kt#L46-L48

Could be swapped so the engine creation is done before to mimic the fix from the issues you have found.

Ideally you know of a way to produce the crash so that we'd know if that fixes the issue as it seems to not be really testable according to the linked issue.

Would you be up to create a PullRequest with the change?

ABausG avatar Jun 05 '22 21:06 ABausG

Thanks for the reply. Unfortunately I can't reproduce this. They are crashes that I have been made aware of through Google Play console.

I'll try to switch those two lines around and see if it stops those errors. I had another two instances of the error in the last 72 hours, so I'll make the switch and monitor for errors.

roly151 avatar Jun 19 '22 06:06 roly151