You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This fixes the longstanding crash from playing back too many demos.
The basic issue was that when demos were played back it loaded in the models with a protected flag that prevented some of them from being deleted when the demo stopped. This meant that every time a new map was loaded it would slowly increase until the cache (256MB) didn't have enough space causing a crash :(. Repeatedly playing the demos of the same map doesn't cause the crash it's gotta be unique maps/model data.
I tried a few things to fix it, like forcibly unloading the models, that just crashes the game. Using built-in Valve commands (flush_locked explicitly flushes these resources) on demo stop, also just crashes the game. Just upping the cache limit to 512MB, which actually worked and made the cache sufficiently sized such that you could playback the entire SP or Coop campaign without crashing. It just wasn't a fix for the core issue so I abandoned it.
The solution I ended up on is whenever a demo stops it looks through the models cache and changes the flags to be ones the game is willing to cleanup. From there the game cleans them up appropriately by itself which nicely fixes the issue :).
Variable is sv_cheats protected because it has no need for working in a run, and it'd be pointless to waste time testing whether or not it can somehow actually break something.
Tested Portal 2 + all the mods on windows + linux (if Linux is supported). Pretty sure Valve just never changed anything related to this across all the engine versions so it kind of just worked out nicely.
Oh yeah if you wanted to test this yourself you can use the command cache_print_summary at the end of every demo.
Section [ModelData]: 0 resources total 0 bytes, 0.00 % of limit (256 MB)
Section [ModelMesh]: 0 resources total 0 bytes, 0.00 % of limit (256 MB)
Section [AnimBlock]: 0 resources total 0 bytes, 0.00 % of limit (256 MB)
Section [ColorMesh]: 0 resources total 0 bytes, 0.00 % of limit (256 MB)
Section [Captions]: 0 resources total 0 bytes, 0.00 % of limit (64 KB)
As you play more unique maps in demos (without the fix active) you'll find ModelMesh grows rather rapidly!
Love it! I'll just get you to regenerate docs/cvars.md whenever you add/remove/etc cvars (see #p2sr-dev pins), and fix a slight code smell by noting // namespace on the closing brace, which is preferred on long blocks / ifdefs where the initiator may be unclear.
Have you tested this on other mods too? NBD if not, it will correctly disable if the sig fails...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the longstanding crash from playing back too many demos.
The basic issue was that when demos were played back it loaded in the models with a protected flag that prevented some of them from being deleted when the demo stopped. This meant that every time a new map was loaded it would slowly increase until the cache (256MB) didn't have enough space causing a crash :(. Repeatedly playing the demos of the same map doesn't cause the crash it's gotta be unique maps/model data.
I tried a few things to fix it, like forcibly unloading the models, that just crashes the game. Using built-in Valve commands (flush_locked explicitly flushes these resources) on demo stop, also just crashes the game. Just upping the cache limit to 512MB, which actually worked and made the cache sufficiently sized such that you could playback the entire SP or Coop campaign without crashing. It just wasn't a fix for the core issue so I abandoned it.
The solution I ended up on is whenever a demo stops it looks through the models cache and changes the flags to be ones the game is willing to cleanup. From there the game cleans them up appropriately by itself which nicely fixes the issue :).
Variable is sv_cheats protected because it has no need for working in a run, and it'd be pointless to waste time testing whether or not it can somehow actually break something.
Tested Portal 2 + all the mods on windows + linux (if Linux is supported). Pretty sure Valve just never changed anything related to this across all the engine versions so it kind of just worked out nicely.