BUG: SpriteCache::removeOldest: Attempted to remove sprite that does not exist

Started by GarageGothic, Sun 29/03/2009 08:33:56

Previous topic - Next topic

GarageGothic

I found an interesting new bug. Basically I have a DynamicSprite that is continuously updated (recreated from screenshot, never deleted). I kept setting this sprite as the background of different GUIs, updating it every time and resizing to the current GUIs width and height, without removing the background from the old GUI currently using it. I did it well knowing that it could cause problems, as part of a test during debugging.

If the new sprite was smaller than the size of the old GUI it was currently the background of, the old GUI would return to its default background color. If the old GUI was smaller, it would just crop the new background. But after a few times of switching back and forth between small and big GUIs, the game crashed with this error:

QuoteAn internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.12.1072)

Error: SpriteCache::removeOldest: Attempted to remove sprite 627 that does not exist

It's not really an issue since I would never use this method in a real game, but nevertheless it's probably something that the engine should be able to handle.

Pumaman

Can you upload a test game that demonstrates the problem, or post the detail of what you're doing in your scripts to cause this?

GarageGothic

Strangely enough, I can't recreate it when moving the scrip to a new game. I have lots of DynamicSprite manipulation going on at the same time in the game I originally tested it with, so it could be I'm somehow overloading the DynamicSprite handler. The crash is directly related to right clicking on the GUIs though (to make them transparent), so it does seem to be caused by the newly added code. The DynamicSprite pointer in the new code is not used in any of the other functions.

By the way, I discovered that updating the sprite doesn't cause the old GUI that was using it to be cleared - there it is substituted by one of the first sprites (1-5) imported into the game and cycles between them with every new update. I should also mention that the sprite number in the bug is not among my imported sprites, so I'm guessing it's a DynamicSprite.

I'm uploading a version that is NOT crashing in case you can use it for anything, but there's too many scripts running in the version that DOES crash for it to be useful. I will try troubleshooting the crashing game by removing the other running scripts one by one, but I don't really have the time right now.

The non-crashing game: http://shadowplaygame.googlepages.com/spritecachebug.rar
Right click GUIs to make them create and use DynamicSprite.

Pumaman

Can you try upgrading to 3.1.2 SP1 just to make sure, though I wouldn't expect it to fix this.

Thanks for the upload, I'll take a look. If you are able to upload a version that does crash, that would be great.

SMF spam blocked by CleanTalk