onscreen/native: Add ref to dumb buffer when using as scanout buffer

Each next and current scanout buffer has a reference on them making sure
they stay alive. When dumb buffers were used on the secondary GPU state,
this didn't happen, leading to crashes due to unref:ing one time too
many, with backtraces such as

  0) g_type_check_instance_is_fundamentally_a ()
  1) g_object_unref ()
  2) secondary_gpu_release_dumb ()
  3) import_shared_framebuffer ()
  4) update_secondary_gpu_state_post_swap_buffers ()
  5) meta_onscreen_native_swap_buffers_with_damage ()
  6) cogl_onscreen_swap_buffers_with_damage ()
  7) swap_framebuffer ()
  8) clutter_stage_cogl_redraw_view_primary ()
  9) clutter_stage_cogl_redraw_view ()
 10) _clutter_stage_window_redraw_view ()
 11) handle_frame_clock_frame ()

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1746>
This commit is contained in:
Jonas Ådahl 2021-02-24 09:36:52 +01:00 committed by Marge Bot
parent 83e74adb5a
commit 36352f44f9

View File

@ -782,8 +782,7 @@ copy_shared_framebuffer_primary_gpu (CoglOnscreen *onscre
g_object_unref (dmabuf_fb);
g_clear_object (&secondary_gpu_state->gbm.next_fb);
secondary_gpu_state->gbm.next_fb = buffer;
g_set_object (&secondary_gpu_state->gbm.next_fb, buffer);
secondary_gpu_state->cpu.current_dumb_fb = buffer_dumb;
return TRUE;