jwinarske / meta-flutter

Yocto meta layer for recipes related to using Google Flutter Engine
MIT License
45 stars 22 forks source link

flutter-wayland segfaults #28

Closed jwinarske closed 3 years ago

jwinarske commented 3 years ago

Reported as issue on i.MX target

bash-5.0# gdb --args flutter_wayland /usr/share/flutter-gallery/sony/data/flutter_assets/
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-poky-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from flutter_wayland...
Reading symbols from /usr/bin/.debug/flutter_wayland...
(gdb) run
Starting program: /usr/bin/flutter_wayland /usr/share/flutter-gallery/sony/data/flutter_assets/
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
LOG: /usr/src/debug/flutter-wayland/git-r0/git/src/main.cc:65: Arg: /usr/share/flutter-gallery/sony/data/flutter_assets/

Program received signal SIGSEGV, Segmentation fault.
std::function<void (wayland::seat_capability)>::swap(std::function<void (wayland::seat_capability)>&) (__x=..., this=0xffffffffeee8)
    at /usr/include/c++/10.2.0/bits/std_function.h:483
483             std::swap(_M_functor, __x._M_functor);
(gdb) bt
#0  std::function<void (wayland::seat_capability)>::swap(std::function<void (wayland::seat_capability)>&) (__x=...,
    this=0xffffffffeee8) at /usr/include/c++/10.2.0/bits/std_function.h:483
#1  std::function<void(wayland::seat_capability)>::operator=<flutter::WaylandDisplay::WaylandDisplay(size_t, size_t, const std::vector<std::__cxx11::basic_string<char> >&)::<lambda(wayland::seat_capability)> > (__f=..., __f=..., this=0x8)
    at /usr/include/c++/10.2.0/bits/std_function.h:459
#2  flutter::WaylandDisplay::WaylandDisplay (this=0xffffffffefd0, width=<optimized out>, height=<optimized out>, args=...)
    at /usr/src/debug/flutter-wayland/git-r0/git/src/wayland_display.cc:196
#3  0x0000aaaaaaabce04 in flutter::Main (args=...) at /usr/src/debug/flutter-wayland/git-r0/git/src/main.cc:68
#4  0x0000aaaaaaaa59e0 in main (argc=<optimized out>, argv=<optimized out>) at /usr/include/c++/10.2.0/bits/stl_vector.h:102
(gdb)
xobs commented 3 years ago

These are fixed in https://github.com/jwinarske/flutter_wayland/pull/2

I am now able to run flutter_wayland:

bash-5.0# /home/user/flutter_wayland /usr/share/flutter-gallery/sony/data/flutter_assets/
LOG: /opt/Ion/yocto/imx-yocto-bsp/mek-build/tmp/work/cortexa35-mx8-poky-linux/flutter-wayland/git-r0/git/src/main.cc:65: Arg: /usr/share/flutter-gallery/sony/data/flutter_assets/
No seat management present
assets_path: /usr/share/flutter-gallery/sony/data/flutter_assets/
load_aot: 0
flutter: Observatory listening on http://127.0.0.1:44279/aKHoxCMuDic=/

However, nothing appears on the screen. Additionally, I have not yet found a way to make the "Flutter observatory" listen on 0.0.0.0.

xobs commented 3 years ago

Note that https://github.com/jwinarske/flutter_wayland/pull/2/commits/ccbca333c1a9a205bbd108d2a4d94b987e0cc756 may be unnecessary, and was caused by missing files in /run. I now have libinput working, however I still do not have any windows appearing. Even so, I feel that it is important to retain the check, in case it is run on a system that has no inputs or seat management.

At least it's not segfaulting! And many threads are running. But no window.

(gdb) run
Starting program: /home/user/flutter_wayland /usr/share/flutter-gallery/sony/data/flutter_assets/
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
LOG: /opt/Ion/yocto/imx-yocto-bsp/mek-build/tmp/work/cortexa35-mx8-poky-linux/flutter-wayland/git-r0/git/src/main.cc:65: Arg: /usr/share/flutter-gallery/sony/data/flutter_assets/
xdg_wm_base exists
Pointer Present
Keyboard Present
[New Thread 0xfffff250e100 (LWP 1086)]
[New Thread 0xfffff1d0d100 (LWP 1087)]
assets_path: /usr/share/flutter-gallery/sony/data/flutter_assets/
load_aot: 0
[New Thread 0xfffff1155100 (LWP 1088)]
[New Thread 0xfffff0954100 (LWP 1089)]
[New Thread 0xffffe3fff100 (LWP 1090)]
[New Thread 0xffffe2e51100 (LWP 1091)]
[New Thread 0xffffe2650100 (LWP 1092)]
[New Thread 0xfffff0153100 (LWP 1093)]
[New Thread 0xffffe19ff100 (LWP 1094)]
[New Thread 0xffffe12ff100 (LWP 1095)]
[New Thread 0xffffe11fe100 (LWP 1096)]
[New Thread 0xffffd257f100 (LWP 1097)]
flutter: Observatory listening on http://127.0.0.1:32837/7icHMNV8Qps=/
[New Thread 0xffffb6a7f100 (LWP 1098)]
[New Thread 0xffffaa67f100 (LWP 1099)]
[Thread 0xffffaa67f100 (LWP 1099) exited]
[Thread 0xffffe19ff100 (LWP 1094) exited]
[Thread 0xffffe12ff100 (LWP 1095) exited]
[Thread 0xffffb6a7f100 (LWP 1098) exited]
[Thread 0xffffd257f100 (LWP 1097) exited]
[New Thread 0xffffe19ff100 (LWP 1102)]
[Thread 0xffffe19ff100 (LWP 1102) exited]
[New Thread 0xffffd257f100 (LWP 1103)]
[Thread 0xffffd257f100 (LWP 1103) exited]
xobs commented 3 years ago

I managed to get https://github.com/NilsBrause/waylandpp/blob/master/example/egl.cpp to compile and run. Furthermore, I can access the Dart VM from inside flutter_wayland, so I know it's running.

I still don't have a window with flutter_wayland. I will continue looking into why flutter_wayland isn't displaying anything.

xobs commented 3 years ago

I can verify that the fixes in https://github.com/jwinarske/flutter_wayland/pull/2/commits work. The issue is that /usr/share/flutter-gallery/sony/data/flutter_assets/ doesn't actually draw anything, so it never ended up displaying anything on the screen.

After switching to another Flutter program, it's working with those patches.

jwinarske commented 3 years ago

Pretty sure the issue is the waylandpp call that checks for input is blocking, thereby blocking the engine task loop unless there is activity. So once it gets something (touch/mouse/keyboard) it renders. I ended up rewriting the embedder without waylandpp for Toyota last year. I'll look at fixing the blocking issue.

I rolled the commit to pick up your changes.

Thanks again!

jwinarske commented 3 years ago

Closing since the segfault is resolved.