Mobile Map Package doesn't render in MapView even if it loads successfully. Issue started after Runtime upgrade.

982
7
Jump to solution
04-05-2022 09:38 AM
KevinCheriyan
Occasional Contributor

I have an app in AppStudio that contains a map created using a locally stored MMPK. The map was working fine through AppStudio 4 and all associated Runtime versions (<100.10?) But after I upgraded to AppStudio 5.3 and Runtime 100.13, this issue started happening.

This only happens when I test on my iPad Mini 5th gen (v14.8.1). Desktop testing doesn't catch anything.

More importantly, this issue only happens roughly 50% of the time. The other half, MMPK and layers render as they should. 

Instead of the layers or basemap showing up, the map is entirely grey. Here's my relevant code for the map page. This is a basic MapView with Map that loads an MMPK and then a basemap.

 

import QtQuick 2.7
import QtQuick.Layouts 1.1
import QtQuick.Controls.Material 2.1
import QtGraphicalEffects 1.0

import QtPositioning 5.8
import QtSensors 5.3

import ArcGIS.AppFramework 1.0
import Esri.ArcGISRuntime 100.13
import ArcGIS.AppFramework.Networking 1.0
import ArcGIS.AppFramework.Platform 1.0
import QtQuick.Controls 2.11

import "../../shared"
import "../../controls"
import "../../assets"

Component {
    id: mapPage

        MobileMapPackage {
            id:mmpk
            path: config.mmpkPath

            onLoadStatusChanged: {
                console.log("MMPK LOAD status changed", loadStatus)
                if (loadStatus === Enums.LoadStatusLoaded) {
                console.log("loaded")
                mapView.map = mmpk.maps[0]
                mapView.map.basemap = defaultBasemap
                }
            }
            onErrorChanged: {
                console.log(mmpk.path)
                console.log("MMPK Error:", error.message, error.additionalMessage)
            }
            onLoadErrorChanged: {
                console.log("MMPK Load Error: ", loadError.message, loadError.additionalMessage)
            }
        }
        BasemapImageryWithLabels {id:defaultBasemap}
        MapView {
            id:mapView
            anchors.fill: parent
            Component.onCompleted: {
                mmpk.load()
            }
            Map {
                initialViewpoint: ViewpointCenter {
                    center: Point {
                        x: -11e6
                        y: 6e6
                        spatialReference: SpatialReference {wkid: 102100}
                    }
                    targetScale: 9e7
                }
            }
        }
}

 

The console does log the expected load status of "Loaded" or 0 even if the map is grey. No errors are logged ever.

Any ideas why the map doesn't render, or has anyone else experienced the same issues?

Thanks!


--------------------------------------------------
Application Developer, GeoMarvel
1 Solution

Accepted Solutions
KevinCheriyan
Occasional Contributor

The issue is resolved. This happens because I'm trying to load the basemap and set the map at the same time. I changed my code to the following and added a Timer component.

 

        MobileMapPackage {
            id:mmpk
            path: config.mmpkPath

            onLoadStatusChanged: {
                console.log("MMPK LOAD status changed", loadStatus)
                if (loadStatus === Enums.LoadStatusLoaded) {
                console.log("loaded")
                mapView.map = mmpk.maps[0]
                basemapTimer.start()
                }
            }
        }

Timer {
     id: baseMapTimer
     interval: 500
     onTriggered: {
         mapView.map.basemap = defaultBasemap
    }
}

 

This interval of half a second seems to be enough time to set the map before adding the basemap. 

Not sure though why this worked in AppStudio 4 and earlier Runtime versions, but not in 100.13 (and possibly some earlier versions.)


--------------------------------------------------
Application Developer, GeoMarvel

View solution in original post

0 Kudos
7 Replies
Tanner_Yould
Esri Contributor

Hi @KevinCheriyan, I'm not quite sure what may be happening here, but I'd like to try to find out with you. Can you check if you can still interact with the map despite it being not visible and gray? One way you could do that is by adding the following code to your `MapView` component and see if "Viewpoint changed" is logged to the console as you attempt to pan around the map.

onViewpointChanged: {
    console.log("Viewpoint changed");
}

 Let me know if that works, thank you!

Tanner Yould, Samples Product Engineer, ArcGIS Runtime SDK for Qt

Tanner Yould
Samples Product Engineer
ArcGIS Maps SDK for Qt
Esri
KevinCheriyan
Occasional Contributor

Hi @Tanner , 

Thank you for your reply. I added the onViewPointChanged signal to the MapView. It DOES NOT get triggered, when the map is grey/not visible.

I also tried checking if this has anything to do with the MMPK I'm using. I tried using the PalmSprings.mmpk and YellowStone.mmpk from the "Open Mobile Map (mmpk)" AppStudio sample template. Interestingly enough, both of these MMPKs work without issue. Map is never grey and everything renders fine.

But I don't believe there is anything wrong with the MMPK. We've been using the same MMPK for more than a year with no issues. My MMPK is much larger in size than the sample ones I tried (>500MB) if you think that could impact performance. 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
Tanner_Yould
Esri Contributor

Ok, this is helpful. Would you be able and willing to share your MMPK (you can DM it to me if it's not something you'd want to share publicly) so we can test it out on our end? If not, we have a few large MMPKs to try. 

In the meantime, would you be able to report the LayerViewState values as they change in the case when it's gray vs working as expected?

Thank you!

Tanner Yould
Samples Product Engineer
ArcGIS Maps SDK for Qt
Esri
KevinCheriyan
Occasional Contributor

Sorry, I'm not authorized to share our client's MMPK outside our org 😕 

I checked for statusFlags values for a layer that I know is visible at the extent on map-start.

 

 

Component.onCompleted: {                  
 console.log(layerViewState(mapView.map.operationalLayers.get(6)).statusFlags)
}

 

 

And this outputs a value of 2 which, checking the Enums, stands for Not Visible. This is the case whether the map is grey or not. I'm looking into whether I really did this correctly since the layer is visible on the map, but still gives the incorrect (?) enum.

I've been talking to @TrevorFrame with the AppStudio team, and he suggested that this could be a concurrency issue with map being loaded from the MMPK and the basemap being added at the same time. 

I moved 

 

Component.onCompleted: {
     mmpk.load
}

 

this snippet of code into MobileMapPackage{} from MapView{} and this seems to have fixed the problem for the above map code (although for my original, larger map code, it doesn't). The issue is that basemap is not being added anymore. So now, I'm trying to find a way to load the basemap without the rest of the map screwing up. And then figure out why this solution doesn't work for my larger map (code not provided here).


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
KevinCheriyan
Occasional Contributor

The issue is resolved. This happens because I'm trying to load the basemap and set the map at the same time. I changed my code to the following and added a Timer component.

 

        MobileMapPackage {
            id:mmpk
            path: config.mmpkPath

            onLoadStatusChanged: {
                console.log("MMPK LOAD status changed", loadStatus)
                if (loadStatus === Enums.LoadStatusLoaded) {
                console.log("loaded")
                mapView.map = mmpk.maps[0]
                basemapTimer.start()
                }
            }
        }

Timer {
     id: baseMapTimer
     interval: 500
     onTriggered: {
         mapView.map.basemap = defaultBasemap
    }
}

 

This interval of half a second seems to be enough time to set the map before adding the basemap. 

Not sure though why this worked in AppStudio 4 and earlier Runtime versions, but not in 100.13 (and possibly some earlier versions.)


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
Tanner_Yould
Esri Contributor

I'm glad to hear that you were able to resolve the issue! With that in mind, I'm wondering if `MapView`'s `onMapChanged` signal would also work in place of the timer. That way you could set the basemap as soon as the map has changed.

Tanner Yould
Samples Product Engineer
ArcGIS Maps SDK for Qt
Esri
0 Kudos
KevinCheriyan
Occasional Contributor

I tried setting the basemap in the onMapChanged signal, but no success. The grey map appears again. I wish it had worked though, since I try to avoid using timers as much as I can!


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos