Friday, October 8, 2010

Where things stand with HTC's drivers

I acquired a G2 and have been attempting to work around this problem for the last couple of days, and while I think I may have improved it marginally, I also don't think I fixed it.  They will definitely still lockup without warning during either eglSwapBuffers or eglCreateSurface, and there's just no way for me to detect it's going to happen -- everything appears fine, no errors are reported.  When the lockup occurs, you'll see a long string of this:

WARN/SharedBufferStack(2005): waitForCondition(LockCondition) timed out(identity=9, status=0). CPU may be pegged. trying again.
WARN/SharedBufferStack(71): waitForCondition(LockCondition) timed out (identity=9, status=0). CPU may be pegged. trying again.

The thing to note here is that eglSwapBuffers and eglCreateSurface are never, ever supposed to block.  If they can't succeed, they're supposed to return with an error indicating so.  All error checking for these is meant to be done after the fact -- you call them, check if it worked, try again if it didn't.  This means there's nothing built into OpenGL to help with this, and the error is low level enough that it's well below my code's level of visibility.

Behaviorally, this primarily seems to happen upon losing and recreating the OpenGL context during a portrait/landscape switch, and is uncommon in the sense that it happens maybe one or two percent of the time.  Doesn't sound like a lot, but that's actually pretty high if you're using your phone actively.  It happens about 25% of the time if you call glFinish before swapping the buffers -- pretty good evidence it's a race condition.

While I can avoid glFinish easily enough, I must support both portrait and landscape for these wallpapers, as I'm at the mercy of the home screen there.  An application can simply insist in running one or the other and minimize its exposure, but that's not the case with a live wallpaper.  Odds are HTC just didn't test any of the marketplace ones at all, and only tested Google's default wallpapers, which are written with the NDK and take a different route, though I wouldn't be shocked if they lockup occasionally as well.

Since it doesn't appear I can actually fix the problem, I unfortunately need to admit defeat.  I've added a note about locking up on the G2 to all of our market listings and we will offer a refund to G2 owners upon request.  Sorry folks, until HTC looks at the issue there doesn't appear to be anything I can do.

No comments:

Post a Comment