SnowyMouse / chimera

The update to Halo PC that never was
https://chimera.opencarnage.net
GNU General Public License v3.0
147 stars 27 forks source link

Some issues with the background_playback feature. #24

Closed Aerocatia closed 4 years ago

Aerocatia commented 4 years ago

1: The game will crash if the current game changes while tabbed out. I remember that this issue was in a previous version, it happens right after the new game connects.

2: The game will immediately try to grab focus again when the game is tabbed out in full-screen mode. when this happens you will lose input to the game so your only option is to exit with ALT-F4 as you have no other control over the system. This only happens when using native d3d9 as dgVoodoo2 hides this bug by wrapping the video output and window handling.

surrealwaffle commented 4 years ago

Based on some rough testing, subissue two is a result of Halo calling IDirect3DDevice9::Reset() whenever the video device is lost. The code around it has scaffolding so that only a D3DERR_DRIVERINTERNALERROR causes a fatal error, so it should be a matter of redirecting the call to something that just returns D3DERR_DEVICELOST if the window does not have focus. The downside is that when a non-fatal error occurs from the reset, the thread sleeps for 50 milliseconds, so that will probably need to be made adjustable.

Of course, I may have been absurdly lucky with my testing. Either way, I'll report back in a day or two when I have some more information on it.

surrealwaffle commented 4 years ago

Made a little bit of progress on this. I can now remain alt-tabbed with Halo launched in fullscreen and with the background_playback feature active. Unfortunately there are now some serious screen-sizing issues. I'll continue to refine this on my own branch.

surrealwaffle commented 4 years ago

Subissue 2 is addressed by #39, so I'll begin looking at subissue 1. The crashes do not occur when I disable background_playback, so it is likely something similar in nature.

surrealwaffle commented 4 years ago

I have a bit of an update to report. The crash I was observing came from within chimera::display_text, but the implementation of text display in chimera itself is not the problem. On a normal load, Halo will set static tag references for the fonts and presumably other tags for general use. With background_playback active and the application fullscreen and tabbed during a map load to a different map, at least some of these references do not get updated. As a result, the ID for the font tag is stale and may index into a tag of inappropriate type or into garbage memory. I have no fix for this yet, but I can now better direct my efforts.

Edit: The above explanation is wrong. An explanation for the crashes I was experiencing is available in the PR (#41).

Aerocatia commented 4 years ago

Fixed as of 99bc9f8da3ae352a012989fe4d5b4251c61f8051 I'm closing this as I forgot to note the crash happened when you tabbed back in. I think that was the only issue with this feature.