gamescope icon indicating copy to clipboard operation
gamescope copied to clipboard

Prevent SDL_WaitEvent loop from running before wlserver has finished initializing

Open sharkautarch opened this issue 1 year ago • 6 comments

(hopefully) fixes issue https://github.com/ValveSoftware/gamescope/issues/661

Uses ~~C++11 compatible~~ atomic ~~and condition~~ variable ~~(reusing the steamcompmgr "poor man's semaphore" class)~~ This PR only adds synchronization during startup, so not much overhead IMO

I had noticed that issue https://github.com/ValveSoftware/gamescope/issues/661 would be triggered 50% of the time when running ValveSoftware/gamescope/master under intel VTune. Compiling and running gamescope w/ this PR under intel VTune -> haven't seen any occurrences of the issue after running gamescope under VTune 4 different times.

sharkautarch avatar Dec 30 '23 01:12 sharkautarch

You don't need to use the semaphore + condition variable, etc -- you can just use a std::atomic<bool> + .wait + .notify_all on it.

misyltoad avatar Dec 30 '23 16:12 misyltoad

You don't need to use the semaphore + condition variable, etc -- you can just use a std::atomic<bool> + .wait + .notify_all on it.

I was originally thinking of using atomic wait, but I realized that atomic wait is actually only in c++20 and up. Plus I don’t think gcc will compile with c++20 support by default (correct me if I am wrong on that). Wasn’t sure if you wanted gamescope to be able to be c++11 compatible or not.

sharkautarch avatar Jan 01 '24 19:01 sharkautarch

Gamescope already requires C++20

misyltoad avatar Jan 01 '24 19:01 misyltoad

Gamescope already requires C++20

Ah i see, ok I will revise this PR to use atomic + atomic wait instead of the ‘semaphore’

sharkautarch avatar Jan 01 '24 19:01 sharkautarch

You don't need to use the semaphore + condition variable, etc -- you can just use a std::atomic<bool> + .wait + .notify_all on it.

Ok, I've now rewritten the PR to just use std::atomic<bool> + .wait + .notify_one

sharkautarch avatar Jan 01 '24 20:01 sharkautarch

@Joshua-Ashton Could you please re-review this PR?

sharkautarch avatar Feb 28 '24 14:02 sharkautarch

Superseded by commit https://github.com/ValveSoftware/gamescope/commit/be20af6e4f605dc159265a71b85d898643528c5e in upstream gamescope

sharkautarch avatar Jul 02 '24 13:07 sharkautarch