Skip to content

Commit

Permalink
steamcompmgr: Fix rare crash in handle_presented_for_window
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Jan 20, 2024
1 parent 52c8cd7 commit 308a063
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6670,6 +6670,8 @@ void handle_done_commits_xdg()

void handle_presented_for_window( steamcompmgr_win_t* w )
{
// wlserver_lock is held.

uint64_t next_refresh_time = g_SteamCompMgrVBlankTime.schedule.ulTargetVBlank;

uint64_t refresh_cycle = g_nSteamCompMgrTargetFPS && steamcompmgr_window_should_limit_fps( w )
Expand All @@ -6681,8 +6683,6 @@ void handle_presented_for_window( steamcompmgr_win_t* w )
{
if (!lastCommit->presentation_feedbacks.empty() || lastCommit->present_id)
{
wlserver_lock();

if (!lastCommit->presentation_feedbacks.empty())
{
wlserver_presentation_feedback_presented(
Expand All @@ -6703,17 +6703,14 @@ void handle_presented_for_window( steamcompmgr_win_t* w )
lastCommit->present_margin);
lastCommit->present_id = std::nullopt;
}

wlserver_unlock();
}
}

if (struct wlr_surface *surface = w->current_surface())
{
auto info = get_wl_surface_info(surface);
if (info->gamescope_swapchain != nullptr && info->last_refresh_cycle != refresh_cycle)
if (info != nullptr && info->gamescope_swapchain != nullptr && info->last_refresh_cycle != refresh_cycle)
{
wlserver_lock();
if (info->gamescope_swapchain != nullptr)
{
// Could have got the override set in this bubble.s
Expand All @@ -6725,7 +6722,6 @@ void handle_presented_for_window( steamcompmgr_win_t* w )
wlserver_refresh_cycle(surface, refresh_cycle);
}
}
wlserver_unlock();
}
}
}
Expand Down Expand Up @@ -8147,9 +8143,11 @@ steamcompmgr_main(int argc, char **argv)

if ( vblank )
{
wlserver_lock();
gamescope_xwayland_server_t *server = NULL;
for (size_t i = 0; (server = wlserver_get_xwayland_server(i)); i++)
handle_presented_xwayland( server->ctx.get() );
wlserver_unlock();
}

//
Expand Down

0 comments on commit 308a063

Please sign in to comment.