Workaround for an AIR 2.7 Android landscape/GPU fullscreen issue
I'm developing a game with AIR 2.7 and have encountered a very rare and very bizarre issue where if the game is loading while my phone's screen is off (HTC Desire) landscape/GPU fullscreen can break and the game is displayed at 50% of fullscreen scale even though all Stage properties indicate the stage is the correct size.
It's possible to recreate an instance of this issue by using the 'Debug Movie on Device via USB' with the phone's screen off and only unlocking it as the game is loading at the point the "[SWF] android_app.swf - 5863962 bytes after decompression" line has appeared in the Output panel.
Photo of my phone showing this problem attached:

By allowing Auto-orientation in publish settings I found that if this issue had occurred rotating the device instantly corrected it and fullscreen worked. That lead me to find that toggling stage.displayState between "normal" and "fullscreen" also cleared this issue.
Here are the code snippets to highlight what I've added to prevent this issue occuring -- note: var "canvas" is set to stage, global var declarations and the handleActivate event need to be added elsewhere:
private function handleActivate(event:Event):void {
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
// various app specific things I need to do
// ...
fullScreenIssueWorkaround(); // force switch between "normal" and "fullScreen" states to clear
// intermittent fullscreen display issue
}
--
private function updateFullScreenIssueWorkaround():void {
trace("updateFullScreenIssueWorkaround: displayState set to fullScreen");
if(canvas.displayState == "normal") canvas.displayState = "fullScreen";
clearInterval(intervalFullScreenIssueWorkaround);
intervalFullScreenIssueWorkaround = null;
}
private function fullScreenIssueWorkaround():void {
if(! intervalFullScreenIssueWorkaround) {
trace("fullScreenIssueWorkaround: displayState set to normal");
canvas.displayState = "normal";
intervalFullScreenIssueWorkaround = setInterval(updateFullScreenIssueWorkaround, updateFrequency);
}
}
I hope this is of help to somebody out there hitting the same issue!
Simon / iojoe.com
