swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.55k stars 1.11k forks source link

Sway does not reply to xdg_toplevel.set_fullscreen requests made while xdg_toplevel is not mapped #7396

Open afrantzis opened 1 year ago

afrantzis commented 1 year ago

Please fill out the following:

Sway 1.8/wlroots 0.16 does not reply to xdg_toplevel.set_fullscreen requests sent while the xdg_toplevel is not mapped (unless it was just created, in which case it eventually does reply). The scenario can be exhibited by running weston-simple-shm changed as in https://gitlab.freedesktop.org/afrantzis/weston/-/commits/simple-shm-fullscreen to request fullscreen when the first configure event arrives (without attaching any buffers):

# Create xdg_toplevel, commit, wait for first configure
[2867510.049]  -> wl_compositor@5.create_surface(new id wl_surface@3)
[2867510.055]  -> xdg_wm_base@6.get_xdg_surface(new id xdg_surface@7, wl_surface@3)
[2867510.061]  -> xdg_surface@7.get_toplevel(new id xdg_toplevel@8)
[2867510.066]  -> xdg_toplevel@8.set_title("simple-shm-fullscreen")
[2867510.071]  -> xdg_toplevel@8.set_app_id("org.freedesktop.weston.simple-shm-fullscreen")
[2867510.076]  -> wl_surface@3.commit()
[2867510.084]  -> wl_surface@3.damage(0, 0, 250, 250)
[2867510.217] xdg_wm_base@6.ping(14)
[2867510.224]  -> xdg_wm_base@6.pong(14)
# First configure arrives and we ACK it but we do not attach a buffer
# Note: The problem still appears even if we skip the ACK
[2867510.230] xdg_toplevel@8.configure(0, 0, array[0])
[2867510.236] xdg_surface@7.configure(13)
[2867510.242]  -> xdg_surface@7.ack_configure(13)
# We send a fullscreen request, but sway never sends back a configure event
[2867510.246]  -> xdg_toplevel@8.set_fullscreen(nil)
[2867510.251]  -> wl_surface@3.commit()

A similar variation where we skip the ACK can be found at: https://gitlab.freedesktop.org/afrantzis/weston/-/commits/simple-shm-fullscreen-no-ack

This is an issue that also affects Wine Wayland which ends up with similar request patterns.

My understanding of the spec is that there is no requirement for an xdg_toplevel to be mapped to handle such requests.


It may be that this issue is a manifestation of bigger problem, since I noticed that the following scenario is also broken (using the updated weston-simple-shm from https://gitlab.freedesktop.org/afrantzis/weston/-/commits/simple-shm-reconfigure):

  1. create xdg_toplevel, perform initial commit
  2. handle and ack initial configure, commit buffer => surface is now mapped
  3. commit null buffer => surface is newly unmapped
  4. perform initial commit again (as required by the spec) => sway doesn't send back a configure event

I am happy to file a separate issue for this one if people think it has a different root cause.


FWIW, weston/kwin/mutter are happy with these request sequences.

emersion commented 1 year ago

I don't think you can ACK the initial configure then commit without attaching a buffer.

The second bug does sound separate, please file a new issue.

afrantzis commented 1 year ago

I don't think you can ACK the initial configure then commit without attaching a buffer.

I can't find anything in the spec that disallow this, but perhaps I missed something? FWIW, I now tried this sequence without ACKing the configure (so 1. initial commit 2. on configure: no ack, set_fullscreen and commit again), but I am still seeing the same issue.

The second bug does sound separate, please file a new issue.

Done: https://github.com/swaywm/sway/issues/7397

emersion commented 1 year ago

I can't find anything in the spec that disallow this

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/188

afrantzis commented 1 year ago

I can't find anything in the spec that disallow this

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/188

As mentioned above, even if we remove the ACK, the issue still stands. Do you think that the following is an acceptable/in-spec sequence? :

# We receive the initial configure
[2867510.230] xdg_toplevel@8.configure(0, 0, array[0])
[2867510.236] xdg_surface@7.configure(13)
# We send a fullscreen request, but sway never sends back a configure event
[2867510.246]  -> xdg_toplevel@8.set_fullscreen(nil)
[2867510.251]  -> wl_surface@3.commit()

This can be tested with weston-simple-shm from https://gitlab.freedesktop.org/afrantzis/weston/-/commits/simple-shm-fullscreen-no-ack.