mapbox-maps-ios
mapbox-maps-ios copied to clipboard
Stack Overflow in ModelLayer
Environment
- Xcode version: 15.0.1
- iOS version: iOS 16.6.1
- Devices affected:
- Maps SDK Version: 11.0.0
Observed behavior and steps to reproduce
Frequent updates to a ModelLayer's style (using a geojson feature collection of points as a source) eventually cause a stack overflow crash if there are lots of other frequently updating layers and modelScale is set to a zoom interpolated expression. Separately, I think this might have something to do with the duration of animations for modelRotation not calculating properly (If I set model rotation transition to duration=100 seconds the animation takes ~4 seconds to complete, and if the duration less the crash happens less).
In particular, I was able to get it to reliably crash by simultaneously:
- Rotating by 180 degrees every second (setting the
ModelLayer
'smodelRotation
from[0, 0, 0]
to[0, 0, 180]
) - Having
modelRotationTransition
set to duration 100 seconds. - Having
modelScale
set to interpolate based on zoom. Importantly, I was not able to get it to crash ifmodelScale
is just a regular vector like[1, 1, 1]
. Example complexmodelScale
:
modelScale = ['interpolate', ['linear'], ['zoom'],
11,
[['*', 10, 40], ['*', 10, 40], ['*', 10, 40]],
15,
[['*', 5, 40], ['*', 5, 40], ['*', 5, 40]],
];
- Wait 10 seconds to 2 minutes. The more other stuff is moving around (e.g. having a lot of symbols in a SymbolLayer animating by changing the source geojson's coordinates multiple times/second), the quicker the crash seems to happen. However it hasn't been deterministic as to how long it takes.
The models always initially loads and work as expected for a while, with the rotation animating, interpolated scale based on zoom working, and everything rendering correctly. And thanks all the 3d stuff team, it's really awesome :)
Here's the trace:
EXC_BAD_ACCESS: Stack overflow in (null)
0 MapboxCoreMaps +0x301634 mbgl::RenderModelLayer::evaluate(mbgl::PropertyEvaluationParameters const&)
1 MapboxCoreMaps +0x34f688 mbgl::RenderOrchestrator::createRenderTree(std::__1::shared_ptr<mbgl::UpdateParameters> const&, mbgl::ShadowRenderer*)
2 MapboxCoreMaps +0x36d58c mbgl::Renderer::render(std::__1::shared_ptr<mbgl::UpdateParameters> const&)
3 MapboxCoreMaps +0xaad68 mapbox::maps::MapImpl::Impl::render()
4 MapboxCoreMaps +0xa6c2c -[MBMMetalViewDelegate drawInMTKView:]
5 MetalKit +0x204c -[MTKView draw]
6 MapboxMaps +0x10838c MapView.updateFromDisplayLink(displayLink:) (MapView.swift:605:24)
7 MapboxMaps +0x108b08 closure #1 in MapView.didMoveToWindow() (MapView.swift:640:23)
8 MapboxMaps +0xaa568 ForwardingDisplayLinkTarget.update(with:) (ForwardingDispalyLinkTarget.swift:11:9)
9 QuartzCore +0x29324 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long)
10 QuartzCore +0x146e64 CA::Display::DisplayLink::dispatch_deferred_display_links(unsigned int)
11 UIKitCore +0x64dd90 __UIUpdateSequenceRun
12 UIKitCore +0xcb2890 _schedulerStepScheduledMainSection
13 UIKitCore +0xcb1dec _runloopSourceCallback
14 CoreFoundation +0xd3124 ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
15 CoreFoundation +0xdf7b0 ___CFRunLoopDoSource0
16 CoreFoundation +0x645e4 ___CFRunLoopDoSources0
17 CoreFoundation +0x7a0d0 ___CFRunLoopRun
18 CoreFoundation +0x7f3e8 _CFRunLoopRunSpecific
19 GraphicsServices +0x1358 _GSEventRunModal
20 UIKitCore +0x39cf54 -[UIApplication _run]
21 UIKitCore +0x39cbb8 _UIApplicationMain
22 RadiateDev +0xe7f0 0x10000e7f0 (0x10000e778 + 120)
23 dyld +0x15de8 start