Update of screen delayed after changing card

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
KimD
Posts: 225
Joined: Wed Jul 08, 2015 5:51 am

Update of screen delayed after changing card

Post by KimD » Thu Dec 03, 2015 3:33 am

Hi

I'm writing a puzzle to run on Android devices.

There is some heavy lifting in determining the layout of the puzzle, so I've added a "Busy" indicator. This is just a set of dots rotating about a central point. The puzzle, and busy indicator, appear on Card 1. Card 2 is a menu page, which offers the user the option of generating a new puzzle. If the user selects this option, then a global variable (declared on both card 1 and 2) is set to "GiveThemANewPuzzle", and a Go To Card 1 is performed. On Card 1 the OpenCard handler checks the global variable and generates a new puzzle.

On the IDE - Everything works fine. The busy indicator appears on app startup, and when the user selects the "Generate a new puzzle" option. All Good.

As a windows stand alone app (I just thought that I try this) - same as the above. All good.

On the Android emulator, and deployment to real android device - the busy indicator appears on app startup, but NOT when the user selects the "Generate a new puzzle". When the user selects "Generate a new puzzle", android does all of the heavy lifting defined in the OpenCard handler on Card 1, while continuing to display Card 2. Only after Android has finished all of the heavy lifting defined in the OpenCard handler of card 1, does it update the display to show card 1.

I tried inserting the single extra command Answer "Hi" in the first few lines of the OpenCard handler on card 1. With Answer "Hi" in place - Android switches to display Card 1 immediately, then does the heavy lifting. But I don't want an Answer "Hi" in my app ;-)

It seems to me that Android (but not the IDE or Windows) is effectively doing its own Lock Screen, and not unlocking the screen until after the heavy lifting is over.

I've tried doing a search and removing every "Lock Screen" and "Unlock Screen" statement in my code. This made no difference to the way that Android behaved.

Is there a way for me to force Android to update of the display after changing card (other than putting an Answer "Hi" statement in my code)?

Thanks in advance

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Update of screen delayed after changing card

Post by SparkOut » Thu Dec 03, 2015 8:07 am

Try putting all the code in the openCard handler of card 1 into a handler of its own, for this example called "newUpdateHandler". Then change to

Code: Select all

on openCard
   send "newUpdateHandler" to this card in 10 milliseconds
end openCard

KimD
Posts: 225
Joined: Wed Jul 08, 2015 5:51 am

Re: Update of screen delayed after changing card

Post by KimD » Thu Dec 03, 2015 8:24 pm

Thanks for the suggestion, but unfortunately it did not alter the behavior of the app on Android. This continues to display card 2, while executing the code on card 1. It feels like Android is issuing its own "Lock Screen" command, which I can't influence. It is getting the right end-result, but is freezing the display while it calculates it, which means that my "Busy" animation does not get displayed.

Regards

KimD
Posts: 225
Joined: Wed Jul 08, 2015 5:51 am

Re: Update of screen delayed after changing card

Post by KimD » Thu Dec 03, 2015 10:58 pm

Solved - after 5 hours of experimentation

I had "set the acceleratedRendering of this stack to true" in the PreOpenCard handler of Card 1. When I remove this, my problem goes away. I'm GUESSING that part of acceleratedRendering is making some "optimisations" in what is displayed when switch from one card to another; and these optimisations included preventing my "Busy" animation from displaying.

I should have turned acceleratedRendering off earlier. I had read other forum entries that this didn't always speed things up. My puzzle app has pretty simple graphics, and I can't see any motion speed difference with acceleratedRendering on/off, but by turning it off I can get my Busy animation to display. Off it is ;-)

Post Reply