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

xdg_surface has never been configured #330

Closed
SinkinZhu opened this issue Feb 18, 2023 · 15 comments · Fixed by #336
Closed

xdg_surface has never been configured #330

SinkinZhu opened this issue Feb 18, 2023 · 15 comments · Fixed by #336
Labels
bug Something isn't working wayland Topics of Wayland

Comments

@SinkinZhu
Copy link

Dear Sir

When we run our Flutter APP, it start failed, and show the error log : xdg_surface has never been configured
Can you help me introduce how to debug this issue, Thanks

@HidenoriMatsubayashi
Copy link
Contributor

What wayland compositor are you using?

Also, can you please share the whole log?

$ FLUTTER_LOG_LEVELS=TRACE ./flutter-client --bundle=<path_to_flutter_project_bundle>

@makotosato-at
Copy link
Contributor

I got the same issue.
This phenomenon also occurs in RPi4.

This phenomenon seems to occur under the following conditions:

  1. Using weston.
  2. Using video_player or/and camera plugin.
  3. Application is built in release mode.
  4. "$HOME/.cache/gstreamer-1.0/" directory does not exist.

If "$HOME/.cache/gstreamer-1.0/" exists, this phenomenon is not occur.
"$HOME/.cache/gstreamer-1.0/" is created by gst_init().

I don't know the detailed reasons, but it works fine when I try the following:

diff --git a/packages/camera/elinux/camera_elinux_plugin.cc b/packages/camera/elinux/camera_elinux_plugin.cc
index 4f841e0..c72f3dd 100644
--- a/packages/camera/elinux/camera_elinux_plugin.cc
+++ b/packages/camera/elinux/camera_elinux_plugin.cc
@@ -60,7 +60,6 @@ class CameraPlugin : public flutter::Plugin {
                flutter::TextureRegistrar* texture_registrar)
       : plugin_registrar_(plugin_registrar),
         texture_registrar_(texture_registrar) {
-    GstCamera::GstLibraryLoad();
   }
   virtual ~CameraPlugin() {
     if (camera_) {
diff --git a/packages/camera/elinux/gst_camera.cc b/packages/camera/elinux/gst_camera.cc
index 9bb0e47..0f383e8 100644
--- a/packages/camera/elinux/gst_camera.cc
+++ b/packages/camera/elinux/gst_camera.cc
@@ -8,6 +8,7 @@
 
 GstCamera::GstCamera(std::unique_ptr handler)
     : stream_handler_(std::move(handler)) {
+  gst_init(NULL, NULL);
   gst_.pipeline = nullptr;
   gst_.camerabin = nullptr;
   gst_.video_convert = nullptr;
diff --git a/packages/video_player/elinux/gst_video_player.cc b/packages/video_player/elinux/gst_video_player.cc
index 02339e8..f4433f7 100644
--- a/packages/video_player/elinux/gst_video_player.cc
+++ b/packages/video_player/elinux/gst_video_player.cc
@@ -9,6 +9,7 @@
 GstVideoPlayer::GstVideoPlayer(
     const std::string& uri, std::unique_ptr handler)
     : stream_handler_(std::move(handler)) {
+  gst_init(NULL, NULL); 
   gst_.pipeline = nullptr;
   gst_.playbin = nullptr;
   gst_.video_convert = nullptr;
diff --git a/packages/video_player/elinux/video_player_elinux_plugin.cc b/packages/video_player/elinux/video_player_elinux_plugin.cc
index a703e31..a41405a 100644
--- a/packages/video_player/elinux/video_player_elinux_plugin.cc
+++ b/packages/video_player/elinux/video_player_elinux_plugin.cc
@@ -58,9 +58,6 @@ class VideoPlayerPlugin : public flutter::Plugin {
                     flutter::TextureRegistrar* texture_registrar)
       : plugin_registrar_(plugin_registrar),
         texture_registrar_(texture_registrar) {
-    // Needs to call 'gst_init' that initializing the GStreamer library before
-    // using it.
-    GstVideoPlayer::GstLibraryLoad();
   }
   virtual ~VideoPlayerPlugin() {
     for (auto itr = players_.begin(); itr != players_.end(); itr++) {

@HidenoriMatsubayashi
Copy link
Contributor

Ah, if we use camera and video plugins in a same app, it will lead double "gst_init(NULL, NULL)" call in the same app.

@makotosato-at
Copy link
Contributor

Hello.

I could not get FLUTTER_LOG_LEVELS=TRACE log because it only occurs in the release version,
but I could get WAYLAND_DEBUG=1 log instead.

flutter-elinux version is 3.3.10 and I got this log on RPi4.
log.txt

@HidenoriMatsubayashi
Copy link
Contributor

Thanks.

Did mouse cursor is enabled when the error happened? If so, can you please try again using --no-cursor option as a test?

@makotosato-at
Copy link
Contributor

makotosato-at commented Mar 24, 2023

Did mouse cursor is enabled when the error happened? If so, can you please try again using --no-cursor option as a test?

I tried it and it didn't work.
Again, I don't know why, but if $HOME/.cache/gstreamer-1.0 exists, it works fine.
It doesn't seem to have anything to do with weston...

@HidenoriMatsubayashi
Copy link
Contributor

Again, I don't know why, but if $HOME/.cache/gstreamer-1.0 exists, it works fine.

Strange. Does the issue happen even if using only video or camera plugin only?

@makotosato-at
Copy link
Contributor

Strange. Does the issue happen even if using only video or camera plugin only?

Yes.

On my RPi4, if $HOME/.cache/gstreamer-1.0 is not exists, gst_init() takes about 1600ms to execute.
If $HOME/.cache/gstreamer-1.0 exists, it takes 41ms.

This time may be causing the application initialization sequence to be incorrect.

As a test, sleep(1) instead of gst_init() also causes the phenomenon.
video_player_elinux_plugin.cc:

  VideoPlayerPlugin(flutter::PluginRegistrar* plugin_registrar,
                    flutter::TextureRegistrar* texture_registrar)
      : plugin_registrar_(plugin_registrar),
        texture_registrar_(texture_registrar) {
    // Needs to call 'gst_init' that initializing the GStreamer library before
    // using it.
    //GstVideoPlayer::GstLibraryLoad();
    sleep(1);
  }

@HidenoriMatsubayashi
Copy link
Contributor

I was not able to repro the issue. Can you please check if xdg_surface_ack_configure() is called before wl_surface_commit call?

See also: https://aznote.jakou.com/prog/wayland/06.html

@makotosato-at
Copy link
Contributor

I was not able to repro the issue. Can you please check if xdg_surface_ack_configure() is called before wl_surface_commit call?

I attached a log (ng_log.txt) when the phenomenon occurs and a log (ok_log.txt) when it works correctly.
It seems that xdg_surface_ack_configure is called after wl_surface_commit.
ng_log.txt:

...
[4209127.458]  -> wl_surface@15.commit()
...
[4210790.425]  -> wl_surface@15.commit()
...
[4211134.920]  -> xdg_surface@17.ack_configure(205)
[4211135.022] wl_display@1.delete_id(24)
[4211135.061] wl_display@1.delete_id(26)
[4211135.094] wl_display@1.error(xdg_surface@17, 3, "xdg_surface has never been configured")
xdg_surface@17: error 3: xdg_surface has never been configured

ng_log.txt
ok_log.txt

HidenoriMatsubayashi added a commit to HidenoriMatsubayashi/flutter-embedded-linux that referenced this issue Mar 29, 2023
Fixed sony#330

Signed-off-by: Hidenori Matsubayashi <hidenori.matsubayashi@gmail.com>
@HidenoriMatsubayashi
Copy link
Contributor

@makotosato-at I'm not 100% sure, but can you please try #336 patch?

@makotosato-at
Copy link
Contributor

Thank you for the patch.
I tried but it didn't work.

HidenoriMatsubayashi added a commit to HidenoriMatsubayashi/flutter-embedded-linux that referenced this issue Apr 1, 2023
Fixed sony#330

Signed-off-by: Hidenori Matsubayashi <hidenori.matsubayashi@gmail.com>
@HidenoriMatsubayashi HidenoriMatsubayashi added bug Something isn't working and removed waiting for response labels Apr 1, 2023
@HidenoriMatsubayashi
Copy link
Contributor

I've update the patch. Can you please try with it again? Also, please try flullscreen (-f) option and without its option.

@makotosato-at
Copy link
Contributor

Thank you.
It works fine!!

Also, please try flullscreen (-f) option and without its option.

Both ok.

HidenoriMatsubayashi added a commit that referenced this issue Apr 4, 2023
Fixed #330

Signed-off-by: Hidenori Matsubayashi <hidenori.matsubayashi@gmail.com>
@HidenoriMatsubayashi
Copy link
Contributor

Thanks for helping to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wayland Topics of Wayland
Projects
None yet
3 participants