flutter-elinux icon indicating copy to clipboard operation
flutter-elinux copied to clipboard

Failed to create view controller (DRM backend)

Open fayfive opened this issue 3 years ago • 43 comments

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

fayfive avatar Aug 21 '22 05:08 fayfive

You should paste your log.

HidenoriMatsubayashi avatar Aug 21 '22 06:08 HidenoriMatsubayashi

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.

fayfive avatar Aug 21 '22 06:08 fayfive

Please use debug builds.

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

HidenoriMatsubayashi avatar Aug 21 '22 06:08 HidenoriMatsubayashi

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.

fayfive avatar Aug 21 '22 06:08 fayfive

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

HidenoriMatsubayashi avatar Aug 21 '22 06:08 HidenoriMatsubayashi

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

fayfive avatar Aug 21 '22 06:08 fayfive

Can you please comment-out drmIsMaster in https://github.com/sony/flutter-embedded-linux/blob/master/src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.cc#L29 and try again?

HidenoriMatsubayashi avatar Aug 21 '22 06:08 HidenoriMatsubayashi

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

HidenoriMatsubayashi avatar Aug 21 '22 06:08 HidenoriMatsubayashi

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?

fayfive avatar Aug 21 '22 06:08 fayfive

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

HidenoriMatsubayashi avatar Aug 21 '22 06:08 HidenoriMatsubayashi

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?

fayfive avatar Aug 21 '22 06:08 fayfive

See https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries

HidenoriMatsubayashi avatar Aug 21 '22 06:08 HidenoriMatsubayashi

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

fayfive avatar Aug 21 '22 07:08 fayfive

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.

HidenoriMatsubayashi avatar Aug 21 '22 07:08 HidenoriMatsubayashi

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

fayfive avatar Aug 21 '22 07:08 fayfive

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

HidenoriMatsubayashi avatar Aug 21 '22 07:08 HidenoriMatsubayashi

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

fayfive avatar Aug 21 '22 07:08 fayfive

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

HidenoriMatsubayashi avatar Aug 21 '22 07:08 HidenoriMatsubayashi

[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.

fayfive avatar Aug 21 '22 07:08 fayfive

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

HidenoriMatsubayashi avatar Aug 21 '22 08:08 HidenoriMatsubayashi

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

fayfive avatar Aug 21 '22 08:08 fayfive

Yes.

HidenoriMatsubayashi avatar Aug 21 '22 08:08 HidenoriMatsubayashi

The device has tow cards card0 and card1

fayfive avatar Aug 21 '22 08:08 fayfive

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

HidenoriMatsubayashi avatar Aug 21 '22 08:08 HidenoriMatsubayashi

[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.

fayfive avatar Aug 21 '22 08:08 fayfive

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 avatar Aug 21 '22 08:08 HidenoriMatsubayashi

And I find that cpu is high performance.

Because you are using debug mode.

HidenoriMatsubayashi avatar Aug 21 '22 08:08 HidenoriMatsubayashi

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 avatar Aug 21 '22 08:08 fayfive

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

HidenoriMatsubayashi avatar Aug 21 '22 08:08 HidenoriMatsubayashi

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.

fayfive avatar Aug 21 '22 09:08 fayfive