Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kindle Fire hitches and texture corruption at 60 fps

Tags:

android

gpu

This appears to be a Fire-specific GPU issue, and I'd appreciate any help or suggestions.

For the most part, my tower-defense game is able to run 60 fps even with dozens of enemies and towers all shooting every which way. However, at seemingly random times (even with nothing happening-- like sitting on the main menu) very evenly spaced 400ms hitches pause the game at an interval of around 2-3 seconds. Then suddenly the hitches will disappear and 16x16 pixel blocks of textures will randomly not render.

These 2 glitches appear to be mutually exclusive and, like I said can be triggered simply by starting the game and navigating from the main menu to the level-select screen, where minimal resources are loaded and little game logic is happening. I use OpenSL for sound effects, and I noted that disabling sfx changed the hitch duration to 280ms.

Then I manually forced the framerate from 60 fps to 30 fps (by inserting a sleep in the frame tick loop), and both glitches disappeared completely.

Here is a screen cap that demonstrates the texture not rendering. This bug happens in all 32-bit render surfaces regardless of depth/stencil values and whether color-clear is on or off.

Thank you!

EDIT: Actually, apparently the texture flicker happens at any framerate, however, somewhere under between 40 and 45 fps the 400ms hitch goes away.

level select screen

main menu

like image 328
Ajas Avatar asked May 30 '12 01:05

Ajas


1 Answers

Ok, this is a very subtle driver bug not necessarily specific to Kindle Fire. I hope to help someone avoid similar pain in the future. I've already outlined the symptoms clearly, but the source of the bug comes from setting the scissor rect.

Essentially, we have many animated UI elements that zoom on and off screen, so we get pretty funky with the scissor rect. The trigger appears to be setting the scissor rect off-screen, then rendering outside the rect horizontally. Doing so puts the GPU in some subtly screwed up state, which doesn't seem to manifest immediately, but gradually grows worse.

Additionally this appears to have fixed a bug we've had on Droid RAZR, which has a GPU in common with the Fire. The bug was a 5-second freeze in the game where we'd see in the logcat:

W/SharedBufferStack(14208): waitForCondition(LockCondition) timed out (identity=173, status=0). CPU may be pegged. trying again.

Obviously these types of bugs are hard to track down and pinpoint exact conditions, but it is definitely related to rendering outside of off-screen scissor rects.

like image 51
Ajas Avatar answered Oct 23 '22 20:10

Ajas