I have the following Delphi code for showing a modal message on Android which worked fine on 10.1 Berlin, but stopped working on Delphi 10.2.1 Tokyo. This procedure now hangs the Android app.
procedure customShowMessage(AMessage: string);
//good idea to have our own procedure that we can tweak, as even for VCL and windows, we have done show message differently over the years due to all sorts of funny problems
var
LModalWindowOpen: boolean;
begin
LModalWindowOpen := true;
TDialogService.MessageDialog(AMessage, TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0,
procedure(const AResult: TModalResult)
begin
LModalWindowOpen := false;
end);
while LModalWindowOpen do
begin
Application.ProcessMessages; //since 10.2 Tokyo, popup never shows and this loops forever
end;
end;
I suspect it possibly has something to do with the change in Tokyo as to how the app runs in the main thread. Not sure what I can replace Application.ProcessMessages with that will let the dialog show, so that the user can click on something.
I have a lot of places this is used, so changing it to work using a callback is going to be a lot of work, and restructuring.
Application.ProcessMessages()
is broken on Android in Tokyo (along with a lot of other things - do you have the latest Update installed?). Besides, modal dialogs are not supported on Android anyway. Embarcadero's documentation says as much. FMX has supported async dialogs since XE5 to address this. You need to rewrite this code to work asynchronously. Get rid of theProcessMessages
loop and let the dialog notify you when it has been closed. Do not block the calling thread waiting for the dialog to close. It is the proper way to handle this. You should not have ignored this in your design. – Remy Lebeau