Nothing Special   »   [go: up one dir, main page]

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

A configure is scheduled for an uninitialized xdg_surface #1372

Closed
Narrat opened this issue Dec 27, 2023 · 6 comments
Closed

A configure is scheduled for an uninitialized xdg_surface #1372

Narrat opened this issue Dec 27, 2023 · 6 comments
Labels
bug Something isn't working PR pending PR to fix the issue is already pending
Milestone

Comments

@Narrat
Copy link
Contributor
Narrat commented Dec 27, 2023

Noticed this output in the labwc log. But I cannot tell if this comes from labwc or wlroots. Or if this a warning, an error or something that should be covered? (I lean to error, because it is written in red)
Or moved to upstream for the offending program(s).
Didn't find a reference in the repo (issues, pr, discussion)

Example:

00:00:12.657 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b5247f4a70
00:00:18.294 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b5245295b0
00:00:19.663 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b524823160
00:00:26.856 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b5245296c0
00:00:27.985 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b5245296c0
00:00:29.227 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b5245296c0
00:05:51.187 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b5245296c0
00:05:55.742 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b52484ae30
00:05:55.997 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b5248174c0
00:05:59.840 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b52484ae30
00:06:01.927 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0x55b524816370

How to reproduce: Happens for example with waybar and the tooltip for modules (if enabled for a module those appear if hovering with the mouse above).

Edit: Ha.. there is a discussion: #1365 Not found because of typo

@Consolatis
Copy link
Member
Consolatis commented Jan 14, 2024

I vaguely remember something about wlroots changing the xdg_surface event flow so that it now (with wlroots 0.17) triggers at an earlier state than it was with wlroots 0.16. Thus what *might* happen here is that we try to position the popup before it was properly initialized. If that is indeed the culprit we may need to listen to another signal before positioning the popup. I assume this change is listed in the breaking changes of wlroots 0.17 but I didn't verify.

@johanmalm
Copy link
Collaborator

I did have a quick look at this when OP first posted. Nefsen402 scene-graph branch of sway issued the same message with waybar (just fewer of them). Might be a wlroots thing we need to patch. Just haven't had a chance to look further yet.

@johanmalm johanmalm added this to the 0.7.1 milestone Jan 14, 2024
@Consolatis
Copy link
Member
Consolatis commented Feb 23, 2024

This can be reproduced easily nested + waybar tooltips (I have an older waybar version here though, no clue if its also reproducible with a recent version, I assume yes).

Added some debug logging and the issue seems to be that we are calling wlr_xdg_popup_unconstrain_from_box() before the popup is ready. I'll debug a bit more.

00:00:06.200 [types/wlr_compositor.c:692] New wlr_surface 0xaaaaabd68760 (res 0xaaaaabd66460)
00:00:06.201 [types/xdg_shell/wlr_xdg_surface.c:388] new xdg_surface 0xaaaaabd68ba0 (res 0xaaaaabd68cc0)
00:00:06.201 [../src/layers.c:337] new layer popup
00:00:06.201 [../src/layers.c:272] creating layer popup
00:00:06.201 [../src/layers.c:289] wlr_xdg_popup_unconstrain_from_box - start
00:00:06.201 [types/xdg_shell/wlr_xdg_surface.c:169] A configure is scheduled for an uninitialized xdg_surface 0xaaaaabd68ba0
00:00:06.201 [../src/layers.c:291] wlr_xdg_popup_unconstrain_from_box - end

Edit:
wlr_xdg_popup_unconstrain_from_box() indeed schedules a configure. So this seems completely on us and waybar has likely nothing to do with it (other than highlighting this bug).

Edit 2:
This seems to solve it (basically delaying the unconstrain until after the initial commit):

unconstrain.diff
diff --git a/include/layers.h b/include/layers.h
index d64c434f..52583035 100644
--- a/include/layers.h
+++ b/include/layers.h
@@ -28,6 +28,7 @@ struct lab_layer_popup {
 	/* To simplify moving popup nodes from the bottom to the top layer */
 	struct wlr_box output_toplevel_sx_box;
 
+	struct wl_listener commit;
 	struct wl_listener destroy;
 	struct wl_listener new_popup;
 };
diff --git a/src/layers.c b/src/layers.c
index 79cffe94..20e9e683 100644
--- a/src/layers.c
+++ b/src/layers.c
@@ -260,14 +260,35 @@ popup_handle_destroy(struct wl_listener *listener, void *data)
 		wl_container_of(listener, popup, destroy);
 	wl_list_remove(&popup->destroy.link);
 	wl_list_remove(&popup->new_popup.link);
+
+	/* Usually already removed unless there was no commit at all */
+	if (popup->commit.notify) {
+		wl_list_remove(&popup->commit.link);
+	}
+
 	free(popup);
 }
 
+static void
+popup_handle_commit(struct wl_listener *listener, void *data)
+{
+	struct lab_layer_popup *popup =
+		wl_container_of(listener, popup, commit);
+
+	if (popup->wlr_popup->base->initial_commit) {
+		wlr_xdg_popup_unconstrain_from_box(popup->wlr_popup,
+			&popup->output_toplevel_sx_box);
+
+		/* Prevent getting called over and over again */
+		wl_list_remove(&popup->commit.link);
+		popup->commit.notify = NULL;
+	}
+}
+
 static void popup_handle_new_popup(struct wl_listener *listener, void *data);
 
 static struct lab_layer_popup *
-create_popup(struct wlr_xdg_popup *wlr_popup, struct wlr_scene_tree *parent,
-		struct wlr_box *output_toplevel_sx_box)
+create_popup(struct wlr_xdg_popup *wlr_popup, struct wlr_scene_tree *parent)
 {
 	struct lab_layer_popup *popup = znew(*popup);
 	popup->wlr_popup = wlr_popup;
@@ -282,10 +303,13 @@ create_popup(struct wlr_xdg_popup *wlr_popup, struct wlr_scene_tree *parent,
 
 	popup->destroy.notify = popup_handle_destroy;
 	wl_signal_add(&wlr_popup->base->events.destroy, &popup->destroy);
+
 	popup->new_popup.notify = popup_handle_new_popup;
 	wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup);
 
-	wlr_xdg_popup_unconstrain_from_box(wlr_popup, output_toplevel_sx_box);
+	popup->commit.notify = popup_handle_commit;
+	wl_signal_add(&wlr_popup->base->surface->events.commit, &popup->commit);
+
 	return popup;
 }
 
@@ -297,8 +321,7 @@ popup_handle_new_popup(struct wl_listener *listener, void *data)
 		wl_container_of(listener, lab_layer_popup, new_popup);
 	struct wlr_xdg_popup *wlr_popup = data;
 	struct lab_layer_popup *new_popup = create_popup(wlr_popup,
-		lab_layer_popup->scene_tree,
-		&lab_layer_popup->output_toplevel_sx_box);
+		lab_layer_popup->scene_tree);
 	new_popup->output_toplevel_sx_box =
 		lab_layer_popup->output_toplevel_sx_box;
 }
@@ -357,8 +380,7 @@ handle_new_popup(struct wl_listener *listener, void *data)
 		.width = output_box.width,
 		.height = output_box.height,
 	};
-	struct lab_layer_popup *popup = create_popup(wlr_popup,
-		surface->tree, &output_toplevel_sx_box);
+	struct lab_layer_popup *popup = create_popup(wlr_popup, surface->tree);
 	popup->output_toplevel_sx_box = output_toplevel_sx_box;
 
 	if (surface->layer_surface->current.layer

I am not really familiar with the popup positioning code but maybe this could give some ideas. Also not sure if the same should / must be done for src/xdg-popup.c.

@charbelnicolas
Copy link

I'm getting this error all the time while using chromium:

ss_2024_02_23_22_27_42

@Consolatis
Copy link
Member

I'm getting this error all the time while using chromium:

ss_2024_02_23_22_27_42

That indeed sounds like the same issue for xdg popups and could likely be solved the same way: by delaying popup_unconstrain() to the first commit rather than when creating the popup.

Consolatis added a commit to Consolatis/labwc that referenced this issue Feb 24, 2024
Consolatis added a commit to Consolatis/labwc that referenced this issue Feb 24, 2024
@Consolatis Consolatis added bug Something isn't working PR pending PR to fix the issue is already pending labels Feb 24, 2024
@Consolatis
Copy link
Member

I added the fix for layershell clients like waybar and also for the usual popup case so Chromium should now also be fine.

Testing would be much appreciated so that we can include the fix in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR pending PR to fix the issue is already pending
Projects
None yet
Development

No branches or pull requests

4 participants