Android app crashed if call FlutterMain#startInitialization late?

545 views
Skip to first unread message

李少杰

unread,
Jun 9, 2018, 4:59:06 AM6/9/18
to Flutter Dev
I was integrating flutter to an existing app which has a custom application class already. Everything works fine if I call FlutterMain#startInitialization in Application#onCreate.
But I want to init flutter just before the FlutterActivity start, so I move it into MyFlutterActivity#onCreate. Then it crashed every time. Does the execution time of startInitialization matter for flutter?

Crash stack trace:
06-09 16:01:29.154 24103 24459 F libc    : Fatal signal 11 (SIGSEGV) in tid 24459 (1.ui)
06-09 16:01:29.258 16803 16803 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-09 16:01:29.258 16803 16803 F DEBUG   : Build fingerprint: 'Android/sdk_google_phone_x86/generic_x86:6.0/MASTER/4729342:userdebug/test-keys'
06-09 16:01:29.258 16803 16803 F DEBUG   : Revision: '0'
06-09 16:01:29.258 16803 16803 F DEBUG   : ABI: 'x86'
06-09 16:01:29.258 16803 16803 F DEBUG   : pid: 24103, tid: 24459, name: 1.ui  >>> li.joker.tutorial <<<
06-09 16:01:29.258 16803 16803 F DEBUG   : signal 11 (SIGSEGV), code 0 (SI_USER), fault addr 0x0
06-09 16:01:29.266 16803 16803 F DEBUG   :     eax 00000000  ebx 9490caac  ecx 00000000  edx 00000000
06-09 16:01:29.267 16803 16803 F DEBUG   :     esi 917abdf8  edi 917abdfc
06-09 16:01:29.267 16803 16803 F DEBUG   :     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000007  xss 0000007b
06-09 16:01:29.267 16803 16803 F DEBUG   :     eip 93c16a19  ebp 958f2618  esp 958f25f0  flags 00210286
06-09 16:01:29.269 16803 16803 F DEBUG   : 
06-09 16:01:29.269 16803 16803 F DEBUG   : backtrace:
06-09 16:01:29.270 16803 16803 F DEBUG   :     #00 pc 004bea19  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #01 pc 004bc5df  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #02 pc 004c32e8  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #03 pc 004c42d6  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #04 pc 000aff8f  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #05 pc 000add90  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #06 pc 000ae0a0  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #07 pc 000ad9f7  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #08 pc 0067ac2e  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #09 pc 0067aa93  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so
06-09 16:01:29.270 16803 16803 F DEBUG   :     #10 pc 00000776  <unknown>
06-09 16:01:29.270 16803 16803 F DEBUG   :     #11 pc 0003202e  <unknown>
06-09 16:01:29.270 16803 16803 F DEBUG   :     #12 pc 00031eab  <unknown>
06-09 16:01:29.270 16803 16803 F DEBUG   :     #13 pc 00028d4a  <unknown>
06-09 16:01:29.270 16803 16803 F DEBUG   :     #14 pc 00028259  <unknown>
06-09 16:01:29.270 16803 16803 F DEBUG   :     #15 pc 00027d7f  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #16 pc 0002731d  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #17 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #18 pc 00020878  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #19 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #20 pc 000229a4  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #21 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #22 pc 00020878  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #23 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #24 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #25 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #26 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #27 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #28 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #29 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #30 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #31 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #32 pc 000154d1  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #33 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #34 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #35 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #36 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #37 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #38 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #39 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #40 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #41 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #42 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #43 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #44 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #45 pc 000204f7  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #46 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #47 pc 000154d1  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #48 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #49 pc 000145e6  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #50 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #51 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #52 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #53 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #54 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #55 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #56 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #57 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #58 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #59 pc 00014106  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #60 pc 00013302  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #61 pc 000113a4  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #62 pc 00010823  <unknown>
06-09 16:01:29.271 16803 16803 F DEBUG   :     #63 pc 0000fa7f  <unknown>
06-09 16:01:29.649 16803 16803 F DEBUG   : 
06-09 16:01:29.649 16803 16803 F DEBUG   : Tombstone written to: /data/tombstones/tombstone_01

李少杰

unread,
Jun 10, 2018, 10:24:06 AM6/10/18
to Flutter Dev
My flutter version:

Flutter 0.4.4 • channel beta • https://github.com/flutter/flutter.git
Framework • revision f9bb4289e9 (4 weeks ago) • 2018-05-11 21:44:54 -0700
Engine • revision 06afdfe54e
Tools • Dart 2.0.0-dev.54.0.flutter-46ab040e58

Mikkel Ravn

unread,
Jun 10, 2018, 12:30:04 PM6/10/18
to sslik...@gmail.com, Flutter Dev
You need to call FlutterMain.startInitialization before you call FlutterMain.ensureInitializationComplete. The latter is called from FlutterActivity.onCreate. So this should work:
public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
FlutterMain.startInitialization(this);
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
I have not been able to reproduce the error you get, so we probably need more details about your code to help out. Please consider creating a GitHub issue for this at https://github.com/flutter/flutter/issues/new/choose

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Mikkel Nygaard Ravn
Software Engineer

Eric Seidel

unread,
Jun 11, 2018, 3:26:14 PM6/11/18
to Mikkel Ravn, sslik...@gmail.com, Flutter Dev
You can also use https://github.com/flutter/engine/wiki/Symbolicating-production-crash-stacks to find out exactly where its crashing.

李少杰

unread,
Jun 11, 2018, 10:48:16 PM6/11/18
to Eric Seidel, Mikkel Ravn, Flutter Dev
Symbolicated stack trace:
Build fingerprint: 'Android/sdk_google_phone_x86/generic_x86:6.0/MASTER/4729342:userdebug/test-keys'
pid: 24103, tid: 24459, name: 1.ui  >>> li.joker.tutorial <<<
signal 11 (SIGSEGV), code 0 (SI_USER), fault addr 0x0
Stack frame #00 pc 004bea19  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine minikin::WordBreaker::setText(unsigned short const*, unsigned int) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../flutter/third_party/txt/src/minikin/WordBreaker.cpp:55
Stack frame #01 pc 004bc5df  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine minikin::LineBreaker::setText() at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../flutter/third_party/txt/src/minikin/LineBreaker.cpp:74
Stack frame #02 pc 004c32e8  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine txt::Paragraph::ComputeLineBreaks() at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../flutter/third_party/txt/src/txt/paragraph.cc:273
Stack frame #03 pc 004c42d6  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine txt::Paragraph::Layout(double, bool) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../flutter/third_party/txt/src/txt/paragraph.cc:428
Stack frame #04 pc 000aff8f  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine blink::ParagraphImplTxt::layout(double) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../flutter/lib/ui/text/paragraph_impl_txt.cc:54
Stack frame #05 pc 000add90  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine blink::Paragraph::layout(double) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../flutter/lib/ui/text/paragraph.cc:80
Stack frame #06 pc 000ae0a0  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine tonic::DartDispatcher<tonic::IndicesHolder<0u>, void (blink::Paragraph::*)(double)>::Dispatch(void (blink::Paragraph::*)(double)) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../topaz/lib/tonic/dart_args.h:150
Stack frame #07 pc 000ad9f7  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine blink::Paragraph_layout(_Dart_NativeArguments*) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../flutter/lib/ui/text/paragraph.cc:36
Stack frame #08 pc 0067ac2e  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine dart::NativeEntry::AutoScopeNativeCallWrapperNoStackCheck(_Dart_NativeArguments*, void (*)(_Dart_NativeArguments*)) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../third_party/dart/runtime/vm/native_entry.cc:198
Stack frame #09 pc 0067aa93  /data/app/li.joker.tutorial-2/lib/x86/libflutter.so: Routine dart::NativeEntry::AutoScopeNativeCallWrapper(_Dart_NativeArguments*, void (*)(_Dart_NativeArguments*)) at /b/build/slave/Linux_Engine/build/src/out/android_debug_x86/../../third_party/dart/runtime/vm/native_entry.cc:168
Stack frame #10 pc 00000776  <unknown>
Stack frame #11 pc 0003202e  <unknown>
Stack frame #12 pc 00031eab  <unknown>
Stack frame #13 pc 00028d4a  <unknown>
. . . . .
Hope it’s helpful.

Mikkel Ravn

unread,
Jun 12, 2018, 2:37:31 AM6/12/18
to 李少杰, Eric Seidel, Flutter Dev

李少杰

unread,
Jun 12, 2018, 4:43:04 AM6/12/18
to Mikkel Ravn, Eric Seidel, Flutter Dev
It seems very same as https://github.com/flutter/flutter/issues/16748. I will add some comment below the issue.

Eric Seidel

unread,
Jun 12, 2018, 11:37:07 AM6/12/18
to 李少杰, jsim...@google.com, Mikkel Ravn, Flutter Dev
+Jason Simmons I believe these all have to do with whether the ICU data file has been expanded correctly onto disk.

However, probably our text system should crash in a more obvious way than this. :)

Jason Simmons

unread,
Jun 12, 2018, 1:01:30 PM6/12/18
to Eric Seidel, sslik...@gmail.com, Mikkel Ravn, flutt...@googlegroups.com
The best solution to this will be eliminating the resource extractor
and serving the ICU data directly out of the APK. Hopefully we can
accomplish this soon.

Jason
Reply all
Reply to author
Forward
0 new messages