sony / flutter-elinux

Flutter tools for embedded Linux (eLinux)
BSD 3-Clause "New" or "Revised" License
408 stars 43 forks source link

Error in running on wayland (NanoPC-T4 board) #215

Closed baharanchi closed 10 months ago

baharanchi commented 10 months ago

I have a NanoPC-T4 development board. I tried to run the sample code on the board on Sway using the commands:

$ sway &
$ flutter-elinux run -d elinux-wayland

But I got the following error:

Launching lib/main.dart on eLinux in debug mode...
Building an eLinux application with wayland backend in debug mode for arm64 target...        36.0s
[ERROR][EnvironmentEgl(22)] Failed to get the EGL display: eglGetError: EGL_SUCCESS
[ERROR][ContextEgl(79)] Failed to choose EGL surface config: eglGetError: EGL_BAD_DISPLAY
[ERROR][CreateOnscreenSurface(118)] Failed to create EGL window surface: eglGetError: EGL_BAD_DISPLAY
[ERROR:flutter/shell/platform/embedder/embedder_surface_gl.cc(121)] Could not create a resource context for async texture uploads. Expect degraded performance. Set a valid make_resource_current callback on FlutterOpenGLRendererConfig.
[ERROR][MakeCurrent(72)] Failed to make the EGL context current: eglGetError: EGL_BAD_DISPLAY
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(44)] Could not make the context current to set up the Gr context.
[ERROR][MakeCurrent(72)] Failed to make the EGL context current: eglGetError: EGL_BAD_DISPLAY
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(82)] Could not make the context current to set up the Gr context.
[ERROR:flutter/shell/common/platform_view.cc(75)] Failed to create platform view rendering surface
[ERROR][DispatchEvent(1263)] Wayland display is invalid.

Here is the output of flutter-elinux devices:

3 connected devices:

Linux (desktop)  • linux          • linux-arm64    • Debian GNU/Linux 11 (bullseye) 4.19.193
eLinux (desktop) • elinux-wayland • flutter-tester • Debian GNU/Linux 11 (bullseye) 4.19.193
eLinux (desktop) • elinux-x11     • flutter-tester • Debian GNU/Linux 11 (bullseye) 4.19.193

I should note that I have no problem running the sample on X11 using the following command: $ flutter-elinux run -d elinux-x11 The problem occurs only in Wayland mode.

HidenoriMatsubayashi commented 10 months ago

Fist of all, Does any native Wayland client (not flutter) app work fine on your board (+sway)?

baharanchi commented 10 months ago

Sway itself works fine and I could run "LXTerminal" on it. But I don't know about any native Wayland client apps. Can you give me an example so I can test it on the board?

HidenoriMatsubayashi commented 10 months ago

How about weston-simple-egl?

baharanchi commented 10 months ago

Executing weston-simple-egl prints Segmentation fault and exits immediately with a return code of 139.

baharanchi commented 10 months ago

weston-simple-shm works fine though.

HidenoriMatsubayashi commented 10 months ago

Okay.

Can you please try the followings?

baharanchi commented 10 months ago

I tried but it made no difference. I got the exact same error. And also weston-simple-egl still produces segmentation fault.

HidenoriMatsubayashi commented 10 months ago

Hmm. Sorry, I can't give you any more advice as I don't have that board. If you have an interest to fix this issue, it would be great you investigate this failure point. For some reason, it looks like eglGetDisplay returns EGL_NO_DISPLAY on your environment.

baharanchi commented 10 months ago

Okay thanks. Is there any difference in terms of performance or features between X11 and Wayland backends? I want to determine if I really need the Wayland backend.

HidenoriMatsubayashi commented 10 months ago

It depends on system requirements and target board spec, but in general x11 system is heavier than wayland in terms of graphics performance and memory footprint. And also x11 requires a number of dependent libraries.

baharanchi commented 10 months ago

What about the produced flutter app executable? Do they behave the same in areas like graphics hardware acceleration? In particular, I use Canvas heavily in my project. Do you expect Canvas to be faster on Wayland than X11?

HidenoriMatsubayashi commented 10 months ago

Do they behave the same in areas like graphics hardware acceleration?

Yes, I think so.

Do you expect Canvas to be faster on Wayland than X11?

I'm not sure. I recommend you to evaluate it first on other arm64 devices such as Raspberry Pi 4 that I've confirmed flutter-elinux (both x11 and wayland) works fine.

HidenoriMatsubayashi commented 10 months ago

@baharanchi Just FYI. If you run flutter with wayland backend, please try to use --async-vblank option to improve performance. See the links below:

baharanchi commented 10 months ago

I solved the problem by changing the Linux image. At first I was using the official Debian image mentioned in the NanoPC-T4 wiki which had the problem. Then I tried the unofficial Armbian image for the device and it resolved the issue. I think it has something to do with this forum post.

There was another problem though. I couldn't run Sway or the sample application with Wayland backend directly from the default desktop. So I decided to run Sway from a tty and then run the sample application from a terminal inside Sway. In order to start the terminal in Sway, you can use Mod + Enter key combinations (Mod is the Super key by default and can be changed in the Sway config file). Also the default terminal in Sway is foot which should be installed using sudo apt install foot (This can also be changed in the Sway config file). I hope this helps anyone who might be having the same problem.

I should also note that I feel Flutter applications have better performance on Wayland than X11 in my experience.