[Wayland][Headless] Mutter crashes if trying to resize a virtual monitor to the same resolution it had before
Affected version
Reproduced with Mutter 40.3 on Fedora 34 using Wayland
Bug summary
If i setup a virtual monitor with resolution 1920x1080 and then try to resize it
by resetting the pipewire stream to the same resolution (1920x1080) Mutter crashes.
Looking at the core dump the virtual stream does not have a virtual monitor associated, it seems that, since the resolution is not changed, pipewire does not trigger meta_screen_cast_virtual_stream_src_notify_params_updated
which would create a virtual monitor via
ensure_virtual_monitor
.
Steps to reproduce
Run mutter in headless mode mutter --wayland --headless
In the same dbus session run the attached reproducer repro_issue.zip
Basically the reproducer setup a virtual monitor with resolution set to 1920x1080, then the pipewire stream is re-initialized with the same resolution as before, this cause the crash.
What happened
Mutter crashed
What did you expect to happen
Not to crash
Relevant logs, screenshots, screencasts etc.
Core was generated by `mutter --wayland --headless'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f7fb9ffa6fc in meta_virtual_monitor_get_crtc (virtual_monitor=0x0) at ../../../../jhbuild/checkout/mutter/src/backends/meta-virtual-monitor.c:99
99 return priv->crtc;
[Current thread is 1 (Thread 0x7f7fb7483a80 (LWP 31899))]
(gdb) bt
#0 0x00007f7fb9ffa6fc in meta_virtual_monitor_get_crtc (virtual_monitor=0x0) at ../../../../jhbuild/checkout/mutter/src/backends/meta-virtual-monitor.c:99
#1 0x00007f7fba0b2822 in view_from_src (src=0x972170) at ../../../../jhbuild/checkout/mutter/src/backends/meta-screen-cast-virtual-stream-src.c:84
#2 0x00007f7fba0b2b6a in add_watch (virtual_src=0x972170) at ../../../../jhbuild/checkout/mutter/src/backends/meta-screen-cast-virtual-stream-src.c:195
#3 0x00007f7fba0b2ceb in init_record_callbacks (virtual_src=0x972170) at ../../../../jhbuild/checkout/mutter/src/backends/meta-screen-cast-virtual-stream-src.c:241
#4 0x00007f7fba0b2dc1 in meta_screen_cast_virtual_stream_src_enable (src=0x972170) at ../../../../jhbuild/checkout/mutter/src/backends/meta-screen-cast-virtual-stream-src.c:274
#5 0x00007f7fba0bbd7d in meta_screen_cast_stream_src_enable (src=0x972170) at ../../../../jhbuild/checkout/mutter/src/backends/meta-screen-cast-stream-src.c:633
#6 0x00007f7fba0bbf8e in on_stream_state_changed (data=0x972170, old=PW_STREAM_STATE_PAUSED, state=PW_STREAM_STATE_STREAMING, error_message=0x0) at ../../../../jhbuild/checkout/mutter/src/backends/meta-screen-cast-stream-src.c:689
#7 0x00007f7fb8609e85 in stream_set_state (stream=0x9c9c80, state=PW_STREAM_STATE_STREAMING, error=0x0) at ../../../../jhbuild/checkout/pipewire/src/pipewire/stream.c:365
#8 0x00007f7fb860adff in impl_send_command (object=0x9c9c80, command=0x7ffc33c116e0) at ../../../../jhbuild/checkout/pipewire/src/pipewire/stream.c:539
#9 0x00007f7fb85e68ed in node_update_state (node=0x9753a0, state=PW_NODE_STATE_RUNNING, res=0, error=0x0) at ../../../../jhbuild/checkout/pipewire/src/pipewire/impl-node.c:324
#10 0x00007f7fb85edff8 in on_state_complete (obj=0x9753a0, data=0x3, res=0, seq=3) at ../../../../jhbuild/checkout/pipewire/src/pipewire/impl-node.c:2042
#11 0x00007f7fb86129d3 in process_work_queue (data=0x977900, count=1) at ../../../../jhbuild/checkout/pipewire/src/pipewire/work-queue.c:86
#12 0x00007f7fa8300875 in source_event_func (source=0xa259a0) at ../../../../jhbuild/checkout/pipewire/spa/plugins/support/loop.c:464
#13 0x00007f7fa82ffca4 in loop_iterate (object=0x9a8bb8, timeout=0) at ../../../../jhbuild/checkout/pipewire/spa/plugins/support/loop.c:309
#14 0x00007f7fba0bcd42 in pipewire_loop_source_dispatch (source=0x991770, callback=0x0, user_data=0x0) at ../../../../jhbuild/checkout/mutter/src/backends/meta-screen-cast-stream-src.c:1015
#15 0x00007f7fb9e795cb in g_main_dispatch (context=0x6ed310) at ../../../../jhbuild/checkout/glib/glib/gmain.c:3344
#16 g_main_context_dispatch (context=0x6ed310) at ../../../../jhbuild/checkout/glib/glib/gmain.c:4062
#17 0x00007f7fb9e79838 in g_main_context_iterate (context=0x6ed310, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../../jhbuild/checkout/glib/glib/gmain.c:4138
#18 0x00007f7fb9e79b13 in g_main_loop_run (loop=0x98baf0) at ../../../../jhbuild/checkout/glib/glib/gmain.c:4336
#19 0x00007f7fba05133a in meta_run_main_loop () at ../../../../jhbuild/checkout/mutter/src/core/main.c:928
#20 0x00007f7fba05134b in meta_run () at ../../../../jhbuild/checkout/mutter/src/core/main.c:943
#21 0x00000000004012a8 in main (argc=1, argv=0x7ffc33c11dc8) at ../../../../jhbuild/checkout/mutter/src/core/mutter.c:78