Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: disable hardware acceleration when GPU driver crashed the game last attempt #10928

Merged
merged 1 commit into from
Jun 4, 2023

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Jun 4, 2023

Motivation / Problem

We have a slow but steady report of "game crashes on startup" over the last few months. All these cases come down to:

  • We start the OpenGL driver
  • The driver crashes for one reason or the other

This leaves the user confused, and they have to dig through tons of things to find out they have to add -v win32 to start the game. Only then they can disable hardware acceleration.

I was wondering: can't we detect if we crashed, and on next start, disable hardware acceleration for the user?

Fixes #10463
Fixes #10394
Fixes #10571

Description

I build this PR on the assumption that Start() causes the driver crash. A few backtraces show this is the case, but a few others we cannot decode; so I am not sure this covers all cases. It might still happen that a crash happens when we actually start drawing for the first time, but we can always extend this code to that later on. For example, by waiting for the first tick to remove the detection file.

Either way, this PR creates a file hwaccel.dat when starting with hardware acceleration. As soon as the first drawing tick finishes, we remove it again. If we try to initialize the video driver with acceleration while that file exist, it means we must have crashed last time. We then disable hardware acceleration.

PS: some changes recently caused those video-driver errors to no longer show up, as they weren't marked critical (any more). I fixed that while I was here. No clue what happened exactly; it used to work, it no longer does, it does now again. shrug

Limitations

Ideally, we find out what gets those drivers to crash; but that has turned out to be very difficult, and often just: known driver bug. Some people seem to never update their drivers, other GPUs haven't release a new drivers in months, and just randomly crash.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@TrueBrain TrueBrain added the backport requested This PR should be backport to current release (RC / stable) label Jun 4, 2023
Copy link
Contributor

@glx22 glx22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't really test myself, but it makes sense.

@TrueBrain TrueBrain enabled auto-merge (squash) June 4, 2023 13:02
@TrueBrain TrueBrain merged commit 0e56a73 into OpenTTD:master Jun 4, 2023
20 checks passed
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this pull request Jun 4, 2023
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this pull request Jun 4, 2023
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this pull request Jun 4, 2023
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this pull request Jun 4, 2023
TrueBrain added a commit that referenced this pull request Jun 4, 2023
@TrueBrain TrueBrain added backported This PR is backported to a current release (RC / stable) and removed backport requested This PR should be backport to current release (RC / stable) labels Jun 5, 2023
mrmbernardi pushed a commit to mrmbernardi/OpenTTD that referenced this pull request Jul 2, 2023
@TrueBrain TrueBrain deleted the try-opengl-once branch January 18, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR is backported to a current release (RC / stable)
Projects
None yet
2 participants