Skip to content

Add a more helpful crash on missing frames#21390

Merged
Mailaender merged 1 commit into
OpenRA:bleedfrom
PunkPun:debug
Aug 4, 2024
Merged

Add a more helpful crash on missing frames#21390
Mailaender merged 1 commit into
OpenRA:bleedfrom
PunkPun:debug

Conversation

@PunkPun

@PunkPun PunkPun commented Apr 6, 2024

Copy link
Copy Markdown
Member

Currently it crashes with: exception of type System.IndexOutOfRangeException: Index was outside the bounds of the array.

With no hint to where the issue resides
This is hot code though it runs only once on game / map start

@anvilvapre anvilvapre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

untested.

Comment thread OpenRA.Game/Graphics/SpriteCache.cs Outdated
@abcdefg30

Copy link
Copy Markdown
Member

From @pchote on Discord:

https://github.com/OpenRA/OpenRA/blob/bleed/OpenRA.Mods.Common/Graphics/DefaultSpriteSequence.cs#L544 is where it is supposed to be handled
i suspect we should be ignoring out of index frames in the cache and then letting that line throw the error
or have some other mechanism for SpriteCache to allow the SpriteSequence to do validation and throw

Would be checking if resolved[f] is in bounds work here?

resolved = r.Frames.Select(f => resolved[f]).ToArray();

And then just if (i >= loadedFrames.Length) continue; in the loop in SpriteCache.

This would have the advantage of being able to report {image}.{Name} in the exception.

@PunkPun

PunkPun commented Apr 25, 2024

Copy link
Copy Markdown
Member Author

That doesn't catch all errors. For example setting an invalid ShadowStart still crashes with out of index, just in a different place

@Mailaender Mailaender left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is already a huge improvement. Thanks!

@Mailaender Mailaender merged commit 014163d into OpenRA:bleed Aug 4, 2024
@Mailaender

Mailaender commented Aug 4, 2024

Copy link
Copy Markdown
Member

Changelog

@PunkPun PunkPun deleted the debug branch August 4, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants