Crash on iOS + MacOS with 100.12

913
5
09-14-2021 04:42 PM
JustinSteventon
New Contributor II

I want to store the viewpoint from the viewpointChanged signal. This works well on PC & Android, but crashes on MacOS and iOS. Actually the crash is intermittent on iOS.

Starting from the QML template, add the following in the MapView:

onViewpointChanged: {           
    let point = GeometryEngine.project(mapView.screenToLocation(width / 2, height / 2), Factory.SpatialReference.createWgs84())           
    //point.x // Weird hack which fixes crash on MacOS/iOS           
    let viewpoint =  ArcGISRuntimeEnvironment.createObject("ViewpointCenter", {center: point, targetScale: mapView.mapScale})           
    console.log(viewpoint.json)       
}

Note that if I uncomment the "point.x", then the crash goes away.

0 Kudos
5 Replies
JamesBallard1
Esri Regular Contributor

Hi @JustinSteventon ,

Thanks for providing the test project. That is very helpful in assisting us with reproducing the problem. Unfortunately, I cannot reproduce the problem on macOS with Qt 5.15.2 or 5.15.5, or with Qt 5.15.5 on iOS. All my tests were with 100.12.

The only tweak I made to the code was this, aside from an API key to get the basemap working.

console.log(JSON.stringify(viewpoint.json))

But even without that change it did not crash.

Can you provide some more information? What version of Qt are you using? Can you provide a stack trace of the crash on macOS? Also, can you confirm if your version of the app has an API key and the basemap is rendering?

0 Kudos
JustinSteventon
New Contributor II

Qt version is 5.15.2 and this is on a Mac M1. Yes, the I am using the sample exactly as attached, but with my own API key. Yes, the basemap does appear when it works.

The crash is intermittent, but seems to happen more often on macOS than iOS. It also seems to be affected by warmup, so after a few successful runs, I could not repro. I switched from Debug to Release and it crashed right away. Looks like a race condition. On my own (more complex app), the crash was consistent.

I have attached a screenshot of the stack.

0 Kudos
JamesBallard1
Esri Regular Contributor

@JustinSteventon, thanks for the extra info.

I still cannot reproduce the problem on my end. One of my colleagues attempted and also couldn't reproduce it. 

The stack trace is limited, so hard to tell from that. Are you able to determine which call is the culprit that's crashing? I can see in the stack it's getting into our Runtime library, but that's all.

Hopefully it's not a Heisenbug that suddenly works fine after you alter the code with some logging.

For example, does this code point to a particular function that's crashing?

onViewpointChanged: {
    console.log("screenToLocation");
    let screenToLocation = mapView.screenToLocation(width / 2, height / 2);
    console.log("Factory.SpatialReference.createWgs84()");
    let sr = Factory.SpatialReference.createWgs84();
    console.log("GeometryEngine.project");
    let point = GeometryEngine.project(screenToLocation, sr);
    console.log("ArcGISRuntimeEnvironment.createObject");
    let viewpoint = ArcGISRuntimeEnvironment.createObject("ViewpointCenter", {center: point, targetScale: mapView.mapScale})
    console.log(JSON.stringify(viewpoint.json))
}

 

0 Kudos
JustinSteventon
New Contributor II

@JamesBallard1 the line that faults consistently is the last one in your snippet, i.e. containing "console.log(viewpoint.json)".

Note, that the snippet misses a log line after the 'viewpoint' creation, but before referencing 'viewpoint.json'. So it seems that the issue is related to creating the json for the ViewpointCenter object.

My repro is 100%, but as soon as I add that "point.x" line, I can no longer repro. The repro is 100% only on MacOS and is less consistent on iOS. However, my app was rejected from the iOS Appstore due to this crash, so it is not just my machine.

I am not blocked, but this kind of bug is a bit worrying. I am not very familiar with MacOS debug symbols, but if you would like to walk me through adding them so you can get a better stack, then I would be happy to help.

0 Kudos
JamesBallard1
Esri Regular Contributor

@JustinSteventon sorry for the delay. I will log an internal issue for the team to keep looking into this. In the meantime I encourage you to open an official support request.

0 Kudos