Closed aperfect closed 3 years ago
As an update, I had time to dig a little more and it seems to be as soon as the map is used within a SwiftUI TabView that the problem occurs.
Any higher up in the view hierarchy and it's fine, but as soon as I try to place SwiftUIMapView within a TabView, it won't render and hits the infinite update loop.
So this works:
VStack {
SwiftUIMapView(mapInitOptions: MapInitOptions(), camera: $camera)
}
But this doesn't:
TabView {
SwiftUIMapView(mapInitOptions: MapInitOptions(), camera: $camera)
.tabItem {
Label("Map", systemName: "map")
}
}
}
Putting inside a NavigationView and referencing with NavigationLink also seems to trigger the issue
Hi @aperfect, I'm having a bit of trouble reproducing this issue. Could you provide a minimal sample project that demonstrates it?
@aperfect I'm not sure if it's related, but there were a couple of other bugs with the SwiftUI example that we're fixing in https://github.com/mapbox/mapbox-maps-ios/pull/467. It may be worth incorporating the patched version to see whether the update loop still occurs.
Hi @macdrevx, thank you for picking this up. I've been able to get the map working with the latest beta so it does seem to be OK now.
Environment
Observed behavior and steps to reproduce
I'm attempting to follow the example code at https://github.com/mapbox/mapbox-maps-ios/blob/main/Apps/Examples/Examples/All%20Examples/SwiftUIExample.swift to migrate to the v10 maps in my SwiftUI app, but any view that includes the UIViewRepresentable hits an infinite loop of updateUIView()s and pegs the CPU to 100%, without getting as far as displaying the map view.
Expected behavior
Expect a map to display
Notes / preliminary analysis
Whether I paste the example code as-is, modify to my own needs or try to simplify to a minimal functionality, it always loops infinitely. I've also tried a much simpler UIViewRepresentable based on the migration 'Display a map' example and that also loops.
Additional links and references