Application->ProcessMessages is not working on Android for Tokyo 10.2 build 2004


Short version:
In Tokyo, for Android only (Samsung S8), Application->ProcessMessages() is not processing user input (button taps, image taps, etc.). Berlin does/did work. Also, it works when compiling to Win32.

Medium version:
I have an Android game that I was developing in Berlin (I stepped away from the project for a while and picked up on it again today). Berlin decided that my registration limit has been exceeded (off-topic, but that is very frustrating in and of itself - motherboard/CPU died and Berlin refused to run afterward). I have a VM with latest Tokyo (build 2004), but didn't want to port this game over to Tokyo yet because I suspected that there would be issues. There are issues... Long story short, the game worked in Berlin, but not in Tokyo. The game that was on my phone was working (built in Berlin). The new deployment does not. Anyone else having this issue? I would love to go back to Berlin, but, alas, registration issues until someone at Embarcadero increases the limit again.

Additional info:
The game loop has a heart beat. Before, during, and when finished with the beat, Application->ProcessMessages is called in order to check for user input (fire button clicked, move button, pause button, etc.). I realize that a timer approach could be used, but I don't want to rewrite code that was working. Is this intentional or a bug? Any thoughts?

Relevant code:

void CHMAGameEngine::Start(TFormHMAGame *formDisp)
int startTick, currentTick, sleepTimeMS;
CHMAPlayer playerGUI;

	this->PGameState = GS_Running;

	while (this->PGameState != GS_Stopped)
		startTick = this->GetTickCountMS();

		formDisp->ProcessInputs(&playerGUI); //has process messages - not working in Tokyo

                //do a bunch of stuff....

		if (this->PGameState == GS_Stopped)

		//process the player from the inputs

                //do a bunch of stuff....


                //process messages until this heartbeat is over
			Application->ProcessMessages(); //not working here either

			currentTick = this->GetTickCountMS();
			sleepTimeMS = this->PBeatTimeMS - (currentTick - startTick);
		while (sleepTimeMS > 0);

		//pause if needed
		while (this->PGameState == GS_Paused)


Responses (1)
  • Accepted Answer

    Monday, December 25 2017, 09:08 AM - #Permalink

    Hmm. The answer may be here:

    It says:

         "Unification of Delphi and Java threads on Android: CallInUIThread has been deprecated. All code is now running in the Java UI Thread, removing the need for thread synchronization.

        The ProcessMessages method used to call the CheckSynchronize method, which called callbacks from the Java Native thread. There used to be two threads: the Delphi UI thread and the Java Native thread. After the refactoring work in 10.2, there is only one thread: the Java Native thread, which receives all notifications from Android and forwards them to the Delphi event handlers. While it is blocked via the while cycle, no event handler can be executed, preventing an exit from the cycle. Callbacks and events in general are called if there is no code holding the app main thread."

    Looks like I'll be rewriting the game loop to be timer based. This significant change should be in the help topic for ProcessMessages.

    The reply is currently minimized Show
Your Reply

Please login to post a reply