nativeshell / examples

Other
64 stars 7 forks source link

Segment fault on linux #4

Closed ikey4u closed 3 years ago

ikey4u commented 3 years ago

Hi, thank you for this awesome project!

Problem

When I run the example, click Window Management/Show Other Window/Call Method or Drag & Drop/File Drag Source, it crashed!

Environment Information

My OS is showed below

image

and version of flutter and rust are given below

❯ flutter --version
Flutter 2.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 02c026b03c (2 weeks ago) • 2021-05-27 12:24:44 -0700
Engine • revision 0fdb562ac8
Tools • Dart 2.13.1
❯ rustc --version
rustc 1.51.0 (2fd73fabe 2021-03-23)

Stack Backtrace

#0  0x00007ffff51a6515 in __strlen_avx2 () at /usr/lib/libc.so.6
#1  0x0000555555a4c5fa in std::ffi::c_str::CStr::from_ptr () at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/ffi/c_str.rs:1173
#2  0x0000555555894919 in nativeshell::shell::platform::key_interceptor::send_platform_message (engine=93825014835536, message=0x7ffff7407910 <fl_engine_platform_message_response_cb(unsigned char const*, unsigned long, void*)>)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/platform/key_interceptor.rs:21
#3  0x00007ffff7407772 in fl_engine_send_platform_message () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#4  0x00005555558dd7bf in nativeshell::shell::platform::platform_impl::flutter::{{impl}}::send_message<nativeshell::shell::platform::platform_impl::flutter::BinaryMessenger,closure-0> (self=0x555555d15ff0, channel=..., message=..., callback=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/platform/linux/flutter.rs:231
#5  0x0000555555893d34 in nativeshell::shell::platform::platform_impl::binary_messenger::PlatformBinaryMessenger::send_message<closure-0> (self=0x555555d15ff0, channel=..., message=..., reply=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/platform/linux/binary_messenger.rs:41
#6  0x000055555583122c in nativeshell::shell::binary_messenger::BinaryMessenger::send_message<closure-0> (self=0x555555d15ff0, channel=..., message=..., reply_callback=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/binary_messenger.rs:53
#7  0x00005555558c8cd9 in nativeshell::codec::message_channel::MessageSender<nativeshell::codec::value::Value>::send_message<nativeshell::codec::value::Value,closure-0> (self=0x7fffffffbe60, message=0x7fffffffbec8, reply=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/codec/message_channel.rs:104
#8  0x0000555555904887 in nativeshell::shell::window_method_channel::WindowMethodChannel::on_message (context=..., handlers=..., message=..., reply=..., engine=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/window_method_channel.rs:171
#9  0x0000555555903c0a in nativeshell::shell::window_method_channel::{{impl}}::new::{{closure}} (message=..., reply=..., engine=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/window_method_channel.rs:96
#10 0x00005555558feaf7 in alloc::boxed::{{impl}}::call<(nativeshell::codec::value::Value, nativeshell::codec::message_channel::MessageReply<nativeshell::codec::value::Value>, nativeshell::shell::engine_manager::EngineHandle),Fn<(nativeshell::codec::value::Value, nativeshell::codec::message_channel::MessageReply<nativeshell::codec::value::Value>, nativeshell::shell::engine_manager::EngineHandle)>,alloc::alloc::Global> (self=0x555555c95130, args=...)
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1535
#11 0x00005555558924f5 in nativeshell::shell::message_manager::MessageManager::on_message (handlers=..., value=..., channel=..., reply=..., engine=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/message_manager.rs:151
#12 0x0000555555892d9f in nativeshell::shell::message_manager::{{impl}}::register_message_channel_for_engine::{{closure}} (value=..., reply=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/message_manager.rs:182
#13 0x00005555558c84f8 in nativeshell::codec::message_channel::{{impl}}::new_with_engine_manager::{{closure}}<nativeshell::codec::value::Value,closure-0> (data=..., reply=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/codec/message_channel.rs:68
#14 0x00005555558936ed in nativeshell::shell::platform::platform_impl::binary_messenger::{{impl}}::register_channel_handler::{{closure}}<closure-0> (bytes=..., channel=..., messenger=..., response=...)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/platform/linux/binary_messenger.rs:28
#15 0x00005555558fee31 in alloc::boxed::{{impl}}::call<(glib::bytes::Bytes, &str, nativeshell::shell::platform::platform_impl::flutter::BinaryMessenger, nativeshell::shell::platform::platform_impl::flutter::BinaryMessengerResponseHandle),Fn<(glib::bytes::Bytes, &str, nativeshell::shell::platform::platform_impl::flutter::BinaryMessenger, nativeshell::shell::platform::platform_impl::flutter::BinaryMessengerResponseHandle)>,alloc::alloc::Global> (self=0x555556179f70, args=...)
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1535
#16 0x00005555558fec98 in alloc::boxed::{{impl}}::call<(glib::bytes::Bytes, &str, nativeshell::shell::platform::platform_impl::flutter::BinaryMessenger, nativeshell::shell::platform::platform_impl::flutter::BinaryMessengerResponseHandle),alloc::boxed::Box<Fn<(glib::bytes::Bytes, &str, nativeshell::shell::platform::platform_impl::flutter::BinaryMessenger, nativeshell::shell::platform::platform_impl::flutter::BinaryMessengerResponseHandle)>, alloc::alloc::Global>,alloc::alloc::Global>
    (self=0x7fffffffc880, args=...) at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1535
#17 0x00005555558dc492 in nativeshell::shell::platform::platform_impl::flutter::message_handler (messenger=0x7fffe0450380, channel=0x7fffe034d210, bytes=0x555556bfa550, response_handle=0x7fffe0198b60, user_data=0x555556179f70)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/platform/linux/flutter.rs:155
#18 0x00007ffff74056d6 in fl_binary_messenger_platform_message_cb(_FlEngine*, char const*, _GBytes*, _FlutterPlatformMessageResponseHandle const*, void*) () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#19 0x00007ffff7407185 in fl_engine_platform_message_cb(FlutterPlatformMessage const*, void*) () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#20 0x00007ffff74b223e in std::__1::__function::__func<FlutterEngineInitialize::$_48, std::__1::allocator<FlutterEngineInitialize::$_48>, void (fml::RefPtr<flutter::PlatformMessage>)>::operator()(fml::RefPtr<flutter::PlatformMessage>&&) ()
    at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#21 0x00007ffff74c028a in flutter::PlatformViewEmbedder::HandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>) () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#22 0x00007ffff78cb354 in std::__1::__function::__func<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_38, std::__1::allocator<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_38>, void ()>::operator()() () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#23 0x00007ffff74bdfb9 in flutter::EmbedderTaskRunner::PostTask(unsigned long) () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#24 0x00007ffff74aa83a in FlutterEngineRunTask () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#25 0x00007ffff7408006 in flutter_source_dispatch(_GSource*, int (*)(void*), void*) () at /home/user/DevSpace/nativeshell-examples/target/debug/lib/libflutter_linux_gtk.so
#26 0x00007ffff52ab02c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#27 0x00007ffff52feb59 in  () at /usr/lib/libglib-2.0.so.0
#28 0x00007ffff52aa593 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#29 0x00007ffff5a3b26f in gtk_main () at /usr/lib/libgtk-3.so.0
#30 0x00005555559e2477 in gtk::auto::functions::main () at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/gtk-0.9.2/src/auto/functions.rs:314
#31 0x00005555558b5efb in nativeshell::shell::platform::platform_impl::run_loop::PlatformRunLoop::run (self=0x555555c95080)
    at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/platform/linux/run_loop.rs:63
#32 0x0000555555831eaf in nativeshell::shell::run_loop::RunLoop::run (self=0x555555c94ec0) at /home/user/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/nativeshell-0.1.3/src/shell/run_loop.rs:64
#33 0x00005555555f87ee in nativeshell_examples::main () at /home/user/DevSpace/nativeshell-examples/src/main.rs:40
knopp commented 3 years ago

Can you please try this with flutter master?

$ flutter channel master
$ flutter upgrade

$ cargo clean
$ cargo run

Stable Flutter version is not supported at this point.

ikey4u commented 3 years ago

Can you please try this with flutter master?

$ flutter channel master
$ flutter upgrade

$ cargo clean
$ cargo run

Stable Flutter version is not supported at this point.

I have upgraded flutter to master version

Flutter 2.3.0-17.0.pre.299 • channel master • https://github.com/flutter/flutter.git
Framework • revision db528a24a3 (24 minutes ago) • 2021-06-10 11:52:42 -0400
Engine • revision 6e03bbd42c
Tools • Dart 2.14.0 (build 2.14.0-196.0.dev)

but now cargo run failed to build the example project, the error is showed below(too long, truncated):

 Caused by:
  process didn't exit successfully: `/home/user/DevSpace/nativeshell-examples/target/debug/build/nativeshell_examples-c9a8405bbd49ffab/build-script-build` (exit code: 101)
  --- stdout

  ** Build failed with error **

  External Tool Failed!
  Status: ExitStatus(ExitStatus(256))
  Command: "\"flutter\" \"assemble\" \"--output=.\" \"--define=BuildMode=debug\" \"--define=TargetPlatform=linux-x64\" \"--define=DarwinArchs=\" \"--define=TargetFile=../../../../../../lib/main.dart\" \"-v\" \"--suppress-analytics\" \"kernel_snapshot\" \"copy_assets\""
  Stderr:
  [ +127 ms] ../../../../../../lib/main.dart:1:8: Error: Error when reading '../../../../../../../../.usr/flutter/flutter_linux_2.2.1-stable/packages/flutter/lib/material.dart': No such file or directory
knopp commented 3 years ago

try to run flutter pub get before building it. it looks like flutter packages need to be upgraded. This is normally done by vscode flutter plugin, but if you're not running vscode you may need to do this manually.

ikey4u commented 3 years ago

try to run flutter pub get before building it. it looks like flutter packages need to be upgraded. This is normally done by vscode flutter plugin, but if you're not running vscode you may need to do this manually.

it works, no crash anymore!

ikey4u commented 3 years ago

@knopp how to hot reload flutter command line in nativeshell?

knopp commented 3 years ago

There are vscode launch configurations in the project that can attach to running app. If you want to do it from command line:

$ flutter attach -d linux --debug-url [observatory url printed at app startup]
knopp commented 3 years ago

i.e.

$ cargo run

...
flutter: Observatory listening on http://127.0.0.1:63604/g3liwgW-epE=/
...

and then

$ flutter attach -d linux --debug-url http://127.0.0.1:63604/g3liwgW-epE=/