WebGMaps Crashing App on Android

We have another problem with the Google Maps component. On windows and iOS, it appears to work fine. But on Android we regularly get the app hanging and completely unresponsive. Looking at the Monitor, we're seeing :


Chromium : [INFO:CONSOLE(34)] "Ignored attempt to cancel a touchscreen event with cancelable=false, for example  because scrolling is in progress and cannot be interrupted.", source : http://maps.google.com/maps/api/js?sensor=false&libraries=panoramio, weather (34).

Is anyone else experiencing hanging in their Maps app ? I can replicate this fairly easily with a map control and a TEdit on a form, then try focusing between the two. Eventually the apps hangs.


Hi,


We haven't received any reports for this issue from other users yet.
Can you please provide the following information so I can further investigate this?
- The version of Delphi you are using
- The version of Android you are using (Please note that v4.4 is the minimum required version)

I'm using Delphi 10.2. This happens on devices with both Marshmallow (Android 6) and Nougat (Android 7).

This was replied to by email.

Despite TMS' best efforts, this is still happening after the latest update. I have no option but to abandon using the component and use TMapView instead. For what I need, it works fine and doesn't exhibit the same errors on Android.

Having upgraded to Delphi 10.2 (Tokyo) I am now getting this which may be the same thing.

This line of code causes an exception on Android:



if GMapsReverseGeocoding1.LaunchReverseGeocoding = erOK then

begin

end



I don't see a problem with the Google maps component itself

An FMX Windows application is fine. Also I am using the latest TMS components.





And it was only after installing the Delphi 10.2 hotfix that I could determine which line of code was causing the exception.

Please note that Embarcadero did breaking changes in the Tokyo release for HTTP request handling on Android specifically (among other breaking changes that also affect Android). So, sadly, these breaking changes affect our WebGMaps geocoding components. We are looking for workarounds for these breaking changes. Given the number of issues with the Android target, we'd really recommend to stick to Delphi 10.1 Berlin till we come up with workarounds and Embarcadero releases an update with fixes.

This problem I have too. I identified in my case is when I use TEDIT, and as soon as it gets the focus, it hangs the application, which even reboots the device. This has since version 10.1 of Radstudio using the component in its latest version.

After examining, I noticed that if there is something in the transfer area (clipboard) of the device it crash, cleaning the transfer area will not cause the problem. But I did not find any solution.

I'm using the latest version of the component and the error persists. I'm also using Radstudio 10.2 Tokyo.

Unfortunately this is a native Android class limitation issue which we have no control over.

[quote=Bart Holvoet]


Unfortunately this is a native Android class limitation issue which we have no control over.
[/QUOTE]

OK, but error only happens when I use the component. If you do not use the component the, application does not crash!

Well, I did debug using component, and I noticed that when there are many objects in the android clippboard, (samsung s7) definitely crash app. In the following observation the code causes the exception, inside the library FMX.Plataform.Android.pas:




if HasClipboard and (TContextMenuItem.Paste in ItemsToShow) and not TextReadOnly then
      begin
        //Paste button
        ResID := TAndroidHelper.GetResourceID('android:string/paste');
        if ResID <> 0 then
          LA.Text := TAndroidHelper.GetResourceString(ResID)
        else
          LA.Text := SEditPaste.ToUpper;
        FPasteButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
        if ResID <> 0 then
          FPasteButton.setText(ResID)  <- problem is here
        else
          FPasteButton.setText(StrToJCharSequence(LA.Text));
        FPasteButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
        FPasteClickListener := TPasteButtonClickListener.Create;
        FPasteButton.setOnClickListener(FPasteClickListener);
        LA.Font.Size := FPasteButton.getTextSize;
        P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
        P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
        if ApproxHeight = 0 then
          ApproxHeight := P.Y + FPasteButton.getPaddingTop + FPasteButton.getPaddingBottom;
      end;

This only happens when I make use of the component, Any solution?

Hi, 


Unfortunately this is a FMX Android class limitation issue that has been acknowledged by Embarcadero but hasn't yet been fixed. For more information please refer to the following QC report:

https://quality.embarcadero.com/browse/RSP-15775



The embarcadero should have an option to disarm the clipboard while you do not have a solution.

Since there is no workaround for this problem, I have done the following to resolve this problem.

1 - In Windows Explorer open the C: \ Program Files (x86) \ Embarcadero \ Studio \ 19.0 \ source \ folder and copy the following file 'FMX.Platform.Android.pas' to another destination folder of your choice.

2 - Open the file and find and comment the following lines (line 1563):

 if HasClipboard and (TContextMenuItem.Paste in ItemsToShow) and not TextReadOnly then
      begin
      { <- BEGIN COMMENT  
    //Paste button
        ResID := TAndroidHelper.GetResourceID('android:string/paste');
        if ResID <> 0 then
          LA.Text := TAndroidHelper.GetResourceString(ResID)
        else
          LA.Text := SEditPaste.ToUpper;
        FPasteButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
        if ResID <> 0 then
          FPasteButton.setText(ResID) 
        else
          FPasteButton.setText(StrToJCharSequence(LA.Text));
        FPasteButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
        FPasteClickListener := TPasteButtonClickListener.Create;
        FPasteButton.setOnClickListener(FPasteClickListener);
        LA.Font.Size := FPasteButton.getTextSize;
        P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
        P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
        if ApproxHeight = 0 then
          ApproxHeight := P.Y + FPasteButton.getPaddingTop + FPasteButton.getPaddingBottom;
}  <- END COMMENT
      end;


Save the file and close.

3 - Open Windows Prompt command and Go to C: \ Program Files (x86) \ Embarcadero \ Studio \ 19.0 \ bin \ folder, run the following command:

C: \ Program Files (x86) \ Embarcadero \ Studio \ 19.0 \ bin> dccaarm.exe c: \ temfolder \ FMX.Platform.Android.pas

After the compilation, two files will be generated: FMX.Platform.Android.dcu and FMX.Platform.Android.o

4- Open radstudio and open your project and add the files FMX.Platform.Android.dcu and FMX.Platform.Android.o (Project> Add to Project in the menu) in your project.

Have fun!

PS1: Do not alter the original files directly, always make a copy of them if there are problems.

PS2: I will not be responsible for any faults, use at your own risk.

Hi, 


While the patch works in your application, it could be possible it doesn't work in other applications. The reason why it crashes at that point is because the memory limit is exceeded. It could very well be a different class, in a different unit. There is unfortunately no workaround for this other than to wait for Embarcadero to fix this major issue.

The error is resolved in QC, does it now work as expected ? Because I'm also still stuck at Delphi 10.1 and the webgmap is a part of my app...