Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to create view controller (DRM backend) #121

Open
fayfive opened this issue Aug 21, 2022 · 43 comments
Open

Failed to create view controller (DRM backend) #121

fayfive opened this issue Aug 21, 2022 · 43 comments
Labels
arm64 Topics to support arm64 target question Further information is requested

Comments

@fayfive
Copy link

fayfive commented Aug 21, 2022

I follow your steps to cross compile with docker.
When I run it on the board, I find that Failed to create view controller FLUTTER_LOG_LEVELS=TRACE FLUTTER_DRM_DEVICE="/dev/dri/card1" /root/bundle/elinux --bundle=/root/bundle
My CPU is rk3568 and my build command flutter-elinux build elinux --target-arch=arm64 --target-sysroot=~/ubuntu18-arm64-sysroot/ --target-backend-type=gbm

@HidenoriMatsubayashi HidenoriMatsubayashi added the question Further information is requested label Aug 21, 2022
@HidenoriMatsubayashi
Copy link
Collaborator

You should paste your log.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

I have FLUTTER_LOG_LEVELS=TRACE . But it just print Failed to create view controller.
or where is the log?

[root@RK356X:~/bundle]# FLUTTER_LOG_LEVELS=TRACE FLUTTER_DRM_DEVICE="/dev/dri/ca
rd1" /root/bundle/elinux  --bundle=/root/bundle
Failed to create view controller.

@HidenoriMatsubayashi
Copy link
Collaborator

Please use debug builds.

flutter-elinux build elinux --target-arch=arm64 --target-sysroot=~/ubuntu18-arm64-sysroot/ --target-backend-type=gbm --debug

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

HA! I see ^_^

[root@RK356X:~/bundle]# FLUTTER_LOG_LEVELS=TRACE FLUTTER_DRM_DEVICE="/dev/dri/ca
rd1" /root/bundle/elinux  --bundle=/root/bundle
[ERROR][ConfigureDisplay(53)] Couldn't get resources
[ERROR][CreateRenderSurface(118)] Failed to create the native window
Failed to create view controller.

@HidenoriMatsubayashi
Copy link
Collaborator

According to the log message, drmModeGetResources failed. I don't know your device, "/dev/dri/card1" is correct?

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

I have tried

[root@RK356X:~/bundle]# FLUTTER_LOG_LEVELS=TRACE FLUTTER_DRM_DEVICE="/dev/dri/ca
rd0" /root/bundle/elinux  --bundle=/root/bundle
[INFO][ConfigureDisplay(71)] resolution: 1280x800
/root/bundle/elinux: symbol lookup error: /root/bundle/lib/libflutter_elinux_gbm.so: undefined symbol: drmIsMaste

But there is error drmIsMaste
It seem to be right when you said that

"/dev/dri/card1" is correct

@HidenoriMatsubayashi
Copy link
Collaborator

@HidenoriMatsubayashi
Copy link
Collaborator

Or can you update your kernel version to more newest version?

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

Or can you update your kernel version to more newest version?

Linux RK356X 4.19.206
Maybe I can't update. Because I don't have all the drivers of this official kernel.

I just want to see the result of elinux flutter. So I don't compile it.

I see it has no the api. Can I update the libdrm to fix it?

@HidenoriMatsubayashi
Copy link
Collaborator

HidenoriMatsubayashi commented Aug 21, 2022

I think the first one is easier than building of the libdrm. Can you try it? After modifying the source file, you can build libflutter_elinux_gbm.so by the following steps in arm64 docker, and replace /root/bundle/lib/libflutter_elinux_gbm.so with the new libflutter_elinux_gbm.so.

$ cmake -DBUILD_ELINUX_SO=ON -DBACKEND_TYPE=DRM-GBM -DCMAKE_BUILD_TYPE=Release -DENABLE_ELINUX_EMBEDDER_LOG=ON -DFLUTTER_RELEASE=OFF ..

See also: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter#build-shared-library-for-flutter-elinux

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

flutter-embedded-linux/build$ cmake -DBUILD_ELINUX_SO=ON -DBACKEND_TYPE=DRM-GBM -DCMAKE_BUILD_TYPE=Release -DENABLE_ELINUX_EMBEDDER_LOG=ON -DFLUTTER_RELEASE=OFF ..
-- The CXX compiler identification is Clang 14.0.0
-- The C compiler identification is Clang 14.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'egl'
--   No package 'egl' found
CMake Error at /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:825 (_pkg_check_modules_internal)
  cmake/package.cmake:6 (pkg_check_modules)
  CMakeLists.txt:41 (include)


-- Configuring incomplete, errors occurred!
See also "/home/alfred/working/da/flutter-embedded-linux/build/CMakeFiles/CMakeOutput.log".

Do I need to set the sysroot?

@HidenoriMatsubayashi
Copy link
Collaborator

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

I need to cross compile, it seem to have no sysroot option?

@HidenoriMatsubayashi
Copy link
Collaborator

HidenoriMatsubayashi commented Aug 21, 2022

After modifying the source file, you can build libflutter_elinux_gbm.so by the following steps in arm64 docker,

Simply, you can build .so file for arm64 on arm64 docker. No sysroot as it's self build on arm64.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

That means I must put the source to the docker, and compile it?

@HidenoriMatsubayashi
Copy link
Collaborator

Yes, that's right. Because it's easy to build than cross-buildings.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

HA! It's too slow.

[ 94%] Building CXX object CMakeFiles/flutter_elinux_gbm.dir/src/flutter/shell/platform/common/client_wrapper/standard_codec.cc.o
make[2]: *** No rule to make target 'libflutter_engine.so', needed by 'libflutter_elinux_gbm.so'.  Stop.
make[2]: *** Waiting for unfinished jobs....
[ 97%] Building CXX object CMakeFiles/flutter_elinux_gbm.dir/src/flutter/shell/platform/common/client_wrapper/plugin_registrar.cc.o
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/flutter_elinux_gbm.dir/all' failed
make[1]: *** [CMakeFiles/flutter_elinux_gbm.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

But it's failed

@HidenoriMatsubayashi
Copy link
Collaborator

Please copy libflutter_engine.so (aarch64 version) to current directory in the docker.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

[root@RK356X:~/bundle]# FLUTTER_LOG_LEVELS=TRACE FLUTTER_DRM_DEVICE="/dev/dri/ca
rd0" /root/bundle/elinux  --bundle=/root/bundle
[INFO][ConfigureDisplay(71)] resolution: 1280x800
[ERROR][EnvironmentEgl(22)] Failed to get the EGL display: eglGetError: EGL_SUCCESS
[ERROR][ContextEgl(33)] Failed to choose EGL surface config: eglGetError: EGL_BAD_DISPLAY
[ERROR][CreateOnscreenSurface(71)] Failed to create EGL window surface: eglGetError: EGL_BAD_DISPLAY
Failed to create view controller.

@HidenoriMatsubayashi
Copy link
Collaborator

HidenoriMatsubayashi commented Aug 21, 2022

eglGetDisplay failed on your device, but I'm not sure why it failed. Your device supports OpenGL ES and EGL?

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

[ERROR][EnvironmentEgl(22)] Failed to get the EGL display: eglGetError: EGL_SUCCESS this one is error?

@HidenoriMatsubayashi
Copy link
Collaborator

Yes.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

The device has tow cards card0 and card1

@HidenoriMatsubayashi
Copy link
Collaborator

Have you set DISPLAY env? Also x11 or wayland is running on your device?

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

[root@RK356X:~/bundle]# env
USER=root
GST_V4L2_PREFERRED_FOURCC=NV12:YU12:NV16:YUY2
WESTON_DISABLE_ATOMIC=1
WESTON_DRM_DISABLE_MODIFIER=1
SHLVL=3
OLDPWD=/
HOME=/
PIXMAN_USE_RGA=1
PAGER=/bin/more 
GST_VIDEO_CONVERT_USE_RGA=1
PS1=[\u@\h:\w]# 
QT_GSTREAMER_PLAYBIN=playbin3
QT_GSTREAMER_WIDGET_VIDEOSINK=waylandsink
TERM=vt102
WESTON_DRM_KEEP_RATIO=1
GST_VIDEO_CONVERT_PREFERRED_FORMAT=NV12:NV16:I420:YUY2
PATH=/bin:/sbin:/usr/bin:/usr/sbin
XDG_RUNTIME_DIR=/var/run
GST_DEBUG_NO_COLOR=1
GST_V4L2_USE_LIBV4L2=1
SHELL=/bin/sh
storagemedia=emmc
PWD=/root/bundle
QT_QPA_PLATFORM=wayland
WESTON_DRM_MIRROR=1
PREFERED_VIDEOSINK=waylandsink
QT_GSTREAMER_WINDOW_VIDEOSINK=waylandsink
GST_VIDEO_FLIP_USE_RGA=1
EDITOR=/bin/vi

Is it here?
I don't know how to see what you said.
The default demo is weston qt.

I find that if I turn on weston and the elinux change to flutter_wayland.so . It works well. That means it has wayland?
And I find that cpu is high performance.

@HidenoriMatsubayashi
Copy link
Collaborator

HidenoriMatsubayashi commented Aug 21, 2022

Did you stop Wayland & Weston before running flutter for DRM? see https://github.com/sony/flutter-embedded-linux/wiki/How-to-run-Flutter-apps#2-run-with-drm-backend

@HidenoriMatsubayashi
Copy link
Collaborator

And I find that cpu is high performance.

Because you are using debug mode.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

if flutter_wayland.so I don't stop the weston.
if flutter_gbm.so I stop the weston, but I don't know how to stop wayland.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

see https://github.com/sony/flutter-embedded-linux/wiki/How-to-run-Flutter-apps#2-run-with-drm-backend

I see that $ Ctrl + Alt + F3 # Switching to CUI but I am elinux not ubuntu. I stop weston is ok? Ctrl + Alt + F3 doesn't work for the system.

@HidenoriMatsubayashi
Copy link
Collaborator

Yes. Please don't launch any window manager using DRM.

@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

Yes. Please don't launch any window manager using DRM.

But it'still

[root@RK356X:~/bundle]# FLUTTER_LOG_LEVELS=TRACE FLUTTER_DRM_DEVICE="/dev/dri/ca
rd0" /root/bundle/elinux  --bundle=/root/bundle
[INFO][ConfigureDisplay(71)] resolution: 1280x800
[ERROR][EnvironmentEgl(22)] Failed to get the EGL display: eglGetError: EGL_SUCCESS
[ERROR][ContextEgl(33)] Failed to choose EGL surface config: eglGetError: EGL_BAD_DISPLAY
[ERROR][CreateOnscreenSurface(71)] Failed to create EGL window surface: eglGetError: EGL_BAD_DISPLAY
Failed to create view controller.

_

@HidenoriMatsubayashi
Copy link
Collaborator

Hmm, I'm afraid that I have no idea to resolve it. It would be great if you investigate/debug this issue.

@HidenoriMatsubayashi HidenoriMatsubayashi added the arm64 Topics to support arm64 target label Aug 21, 2022
@fayfive
Copy link
Author

fayfive commented Aug 21, 2022

It seem that src/flutter/shell/platform/linux_embedded/surface/environment_egl_stream.cc is not compiled, I can't see environment_egl_stream.cc.o?
Which option can compile it?

@sullivanj91
Copy link

sullivanj91 commented Aug 31, 2022

Hi I'm getting a very similar issue when trying to run inside a docker container on a Jetson Nano host. Here is my command/output:

ag@g010-0101-nano:~/mobile/dashboard$ ./build/elinux/arm64/debug/bundle/dashboard 
[WARNING][CreateRenderSurface(111)] FLUTTER_DRM_DEVICE is not set, use /dev/dri/card0
[ERROR][NativeWindowDrm(22)] Couldn't open /dev/dri/card0
[ERROR][CreateRenderSurface(118)] Failed to create the native window
Failed to create view controller.

But the card0 device is mounted to the container:

ag@g010-0101-nano:~/mobile/dashboard$ ls /dev/dri/
card0  renderD128

Is there anything else i can provide to help debug?

@HidenoriMatsubayashi
Copy link
Collaborator

Can you try the same thing outside the docker container?

@sullivanj91
Copy link

Looks like it was a permission issue, I added --group-add=video to my docker run and now it displays. However the container is not able to capture touchscreen input events even with --device=/dev/input/ --group-add=input mounted.

Can you try the same thing outside the docker container?

Both display and input are working when running outside of the container.

@HidenoriMatsubayashi
Copy link
Collaborator

Okay. BTW, which JetPack version are you using?

@sullivanj91
Copy link

After some more debugging this is another permission issue it seems. Added -v /run/udev/data:/run/udev/data to give libinput ability to list devices and then the output is:

[ERROR][operator()(208)] Failed to open /dev/input/event0, error: Permission denied
[ERROR][operator()(208)] Failed to open /dev/input/event2, error: Permission denied
[ERROR][operator()(208)] Failed to open /dev/input/event1, error: Permission denied

I then added --user root and it worked. Trying to figure out now how to give other users permission. --group-add=input is insufficient.

which JetPack version are you using?

Jetpack is 4.9.253-tegra

@HidenoriMatsubayashi
Copy link
Collaborator

Thanks for the information.

@fayfive
Copy link
Author

fayfive commented Sep 3, 2022

Hi I'm getting a very similar issue when trying to run inside a docker container on a Jetson Nano host. Here is my command/output:

ag@g010-0101-nano:~/mobile/dashboard$ ./build/elinux/arm64/debug/bundle/dashboard 
[WARNING][CreateRenderSurface(111)] FLUTTER_DRM_DEVICE is not set, use /dev/dri/card0
[ERROR][NativeWindowDrm(22)] Couldn't open /dev/dri/card0
[ERROR][CreateRenderSurface(118)] Failed to create the native window
Failed to create view controller.

But the card0 device is mounted to the container:

ag@g010-0101-nano:~/mobile/dashboard$ ls /dev/dri/
card0  renderD128

Is there anything else i can provide to help debug?

@sullivanj91
Hello! How can you get the path /dev/dri/card0 on jetson? I can't find the path.
Here is the link that jetson doesn't have the "/dev/dri/card0".
https://forums.developer.nvidia.com/t/why-doesnt-jetson-have-the-directory-of-dev-dri-drm/218578
I'm using jp4.3 and jp4.6

@lizy-coding

This comment was marked as resolved.

@lizy-coding
Copy link

lizy-coding commented Jul 19, 2023

I also ran into this problem, which was eventually solved by finding the right graphical library, my device is
rk3568
SO:Debain 10 aarch64
GPU:libmali-bifrost-g52-g2p0-x11.so
Belongs to the x11 graphical library
Projects generated by
flutter-elinux build elinux --target-arch=arm64 --target-sysroot=/ --target-backend-type=x11 --verbose
will work

@HidenoriMatsubayashi HidenoriMatsubayashi changed the title Failed to create view controller Failed to create view controller (DRM backend) Aug 11, 2023
@HidenoriMatsubayashi HidenoriMatsubayashi changed the title Failed to create view controller (DRM backend) Failed to create view controller (DRM-GBM backend) Aug 11, 2023
@HidenoriMatsubayashi HidenoriMatsubayashi changed the title Failed to create view controller (DRM-GBM backend) Failed to create view controller (DRM backend) Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm64 Topics to support arm64 target question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants