Repository navigation
Open
Labels
bug 🪲Something isn't working
Description
Mapbox Implementation
Mapbox
Mapbox Version
11.8.0
React Native Version
0.76.0
Platform
iOS
@rnmapbox/maps version
10.1.33
Standalone component to reproduce
import React from 'react';
import {
MapView,
RasterSource,
RasterLayer,
Camera,
} from '@rnmapbox/maps';
class BugReportExample extends React.Component {
render() {
return (
<MapView style={{flex: 1}}>
<Camera centerCoordinate={[0,0]} zoomLevel={5} />
<RasterSource tileUrlTemplates={["any LOCAL ZXY path"]} tileSize={256}>
<RasterLayer
minZoomLevel={3}
maxZoomLevel={13}
/>
</RasterSource>
</MapView>
);
}
}Observed behavior and steps to reproduce
- Run the app as many times possible and pan to load the tiles
- In very rare cases (3 per day in a production app with 5000 users), this stack trace will happen
OS Version: iOS 18.2 (22C152)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Crashed Thread: 10 **(This thread number is random every time)**
Application Specific Information:
*** error for object %p: pointer being freed was not allocated
> MyAppName > MyAppName(1724,0x16be8b000) malloc: *** error for object 0x3007949e0: pointer being freed was not allocated
Thread 10 Crashed:
0 libsystem_kernel.dylib 0x3b825e2d4 __pthread_kill
1 libsystem_pthread.dylib 0x42aca059c pthread_kill
2 libsystem_c.dylib 0x32525bb08 abort
3 libsystem_malloc.dylib 0x3361f8bdc <redacted>
4 libsystem_malloc.dylib 0x3361f8850 <redacted>
5 libsystem_malloc.dylib 0x3361f5dc4 <redacted>
6 libcache.dylib 0x466b21a8c cache_set_name
7 CoreFoundation 0x3156deb88 <redacted>
8 CoreUI 0x352495184 <redacted>
9 CoreUI 0x352490320 <redacted>
10 CoreUI 0x3524ab560 <redacted>
11 CoreUI 0x3524ab414 <redacted>
12 CoreUI 0x3524ab2e4 <redacted>
13 CoreUI 0x3524ab124 <redacted>
14 UIKitCore 0x31aa9546c <redacted>
15 UIKitCore 0x31a6e148c <redacted>
16 UIKitCore 0x31a6deff0 <redacted>
17 UIKitCore 0x31aa94954 <redacted>
18 UIKitCore 0x31aa94820 <redacted>
19 UIKitCore 0x31a6ddc8c <redacted>
20 UIKitCore 0x31a6dd778 <redacted>
21 UIKitCore 0x31aa94db0 <redacted>
22 UIKitCore 0x31a82f8ec <redacted>
23 MyAppName 0x204658188 RCTImageFromLocalAssetURL (RCTUtils.m:864)
24 MyAppName 0x2047a9164 -[RCTBundleAssetImageLoader loadImageForURL:size:scale:resizeMode:progressHandler:partialLoadHandler:completionHandler:] (RCTBundleAssetImageLoader.mm:52)
25 MyAppName 0x2047acc94 -[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:561)
26 MyAppName 0x2047aebe4 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:841)
27 MyAppName 0x2047ac090 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:373)
28 MyAppName 0x2047abf88 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:352)
29 MyAppName 0x204b3b67c RNMBXImageQueueOperation.start (RNMBXImageQueue.swift:72)
30 MyAppName 0x20450af68 thunk for closure
31 libdispatch.dylib 0x32515a248 <redacted>
32 libdispatch.dylib 0x32515bfa8 <redacted>
33 libdispatch.dylib 0x32515f0f4 <redacted>
34 libdispatch.dylib 0x32516dec0 <redacted>
35 libdispatch.dylib 0x32516e6c4 <redacted>
36 libsystem_pthread.dylib 0x42ac9b644 _pthread_wqthread
Thread 0
0 MapboxCoreMaps 0x105d871c4 mbgl::FillLayerFactory::getTypeInfo
1 MapboxCoreMaps 0x105cf7b94 mbgl::LayerManagerDefault::addLayerType
2 MapboxCoreMaps 0x105cf7664 mbgl::LayerManagerDefault::LayerManagerDefault
3 MapboxCoreMaps 0x106023fe4 mbgl::style::conversion::Converter<T>::operator()
4 MapboxCoreMaps 0x105c92e14 mapbox::maps::StyleManagerImpl::addStyleLayer
5 MapboxCoreMaps 0x105c1eb54 mapbox::maps::StyleManager::addPersistentStyleLayer
6 MapboxCoreMaps 0x105be1acc -[MBMStyleManager addPersistentStyleLayerForProperties:layerPosition:]
7 MapboxMaps 0x10716f9c0 MBMStyleManager
8 MapboxMaps 0x107166ee0 StyleManager.addPersistentLayer
9 MapboxMaps 0x10716b6bc handleExpected<T>
10 MapboxMaps 0x1071620c8 StyleManager.addLayer
11 MapboxMaps 0x107161f90 StyleManager.addPersistentLayer
12 MapboxMaps 0x1071686c8 StyleManager
13 MapboxMaps 0x1070dd418 AnnotationManagerImpl.init (AnnotationManagerImpl.swift:135)
14 MapboxMaps 0x1070c8acc PointAnnotationManager.init
15 MapboxMaps 0x106ea36b8 [inlined] PointAnnotationManager.init
16 MapboxMaps 0x106ea36b8 [inlined] PointAnnotationManager.__allocating_init (PointAnnotationManager.swift:36)
17 MapboxMaps 0x106ea36b8 [inlined] PointAnnotationManager (<compiler-generated>:30)
18 MapboxMaps 0x106ea36b8 AnnotationOrchestrator.make<T> (AnnotationOrchestrator.swift:154)
19 MapboxMaps 0x106ea21c8 [inlined] AnnotationOrchestrator.make<T>
20 MapboxMaps 0x106ea21c8 AnnotationOrchestrator.makePointAnnotationManager (AnnotationOrchestrator.swift:104)
21 MyAppName 0x204b6d98c RNMBXPointAnnotationManager.init (RNMBXMapView.swift:1594)
22 MyAppName 0x204b598d4 [inlined] RNMBXPointAnnotationManager.init
23 MyAppName 0x204b598d4 [inlined] RNMBXPointAnnotationManager.__allocating_init (RNMBXMapView.swift:1597)
24 MyAppName 0x204b598d4 [inlined] RNMBXMapView.pointAnnotationManager.getter (RNMBXMapView.swift:201)
25 MyAppName 0x204b598d4 RNMBXMapView.pointAnnotationManager.getter (RNMBXMapView.swift:200)
26 MyAppName 0x204b5ba04 RNMBXMapView.applyOnPress (RNMBXMapView.swift:1169)
27 MyAppName 0x204b5b328 RNMBXMapView.Property.apply (RNMBXMapView.swift:383)
28 MyAppName 0x204b740d0 [inlined] thunk for closure
29 MyAppName 0x204b740d0 thunk for closure
30 MyAppName 0x204b74470 thunk for closure
31 MyAppName 0x204b742f4 [inlined] thunk for closure
32 MyAppName 0x204b742f4 thunk for closure
33 MyAppName 0x204b742c0 [inlined] PropertyChanges.apply (PropertyChanges.swift:53)
34 MyAppName 0x204b742c0 [inlined] PropertyChanges.apply
35 MyAppName 0x204b742c0 PropertyChanges.apply
36 MyAppName 0x204b6d7d4 [inlined] thunk for closure
37 MyAppName 0x204b6d7d4 [inlined] thunk for closure
38 MyAppName 0x204b6d7d4 Sequence.forEach
39 MyAppName 0x204b6f3fc [inlined] Sequence.forEach
40 MyAppName 0x204b6f3fc [inlined] PropertyChanges.apply (PropertyChanges.swift:52)
41 MyAppName 0x204b6f3fc RNMBXMapView.didSetProps (RNMBXMapView.swift:752)
42 MyAppName 0x204b5fbf4 [inlined] RNMBXMapView.didSetProps
43 MyAppName 0x204b5fbf4 RNMBXMapView.didSetProps (<compiler-generated>:746)
44 MyAppName 0x204652714 __45-[RCTUIManager _dispatchPropsDidChangeEvents]_block_invoke (RCTUIManager.m:1263)
45 MyAppName 0x204651eac __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke (RCTUIManager.m:1162)
46 MyAppName 0x204651fb0 __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.144 (RCTUIManager.m:1182)
47 libdispatch.dylib 0x32515a248 <redacted>
48 libdispatch.dylib 0x32515bfa8 <redacted>
49 libdispatch.dylib 0x32516aa34 <redacted>
50 libdispatch.dylib 0x32516a64c _dispatch_main_queue_callback_4CF
51 CoreFoundation 0x315679bbc <redacted>
52 CoreFoundation 0x3156761b0 <redacted>
53 CoreFoundation 0x3156c8274 CFRunLoopRunSpecific
54 GraphicsServices 0x3afa214c0 GSEventRunModal
55 UIKitCore 0x31aa2677c <redacted>
56 UIKitCore 0x31a64ce64 UIApplicationMain
57 MyAppName 0x2044f01f0 main (main.m:8)
58 <unknown> 0x1b8cfcde8 <redacted>
Thread 1
0 libsystem_kernel.dylib 0x3b825359c __ulock_wait2
1 libsystem_platform.dylib 0x42ab41d9c <redacted>
2 UIKitCore 0x31a6dd6c0 <redacted>
3 UIKitCore 0x31a82f844 <redacted>
4 MyAppName 0x204658188 RCTImageFromLocalAssetURL (RCTUtils.m:864)
5 MyAppName 0x2047a9164 -[RCTBundleAssetImageLoader loadImageForURL:size:scale:resizeMode:progressHandler:partialLoadHandler:completionHandler:] (RCTBundleAssetImageLoader.mm:52)
6 MyAppName 0x2047acc94 -[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:561)
7 MyAppName 0x2047aebe4 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:841)
8 MyAppName 0x2047ac090 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:373)
9 MyAppName 0x2047abf88 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:] (RCTImageLoader.mm:352)
10 MyAppName 0x204b3b67c RNMBXImageQueueOperation.start (RNMBXImageQueue.swift:72)
11 MyAppName 0x20450af68 thunk for closure
12 libdispatch.dylib 0x32515a248 <redacted>
13 libdispatch.dylib 0x32515bfa8 <redacted>
14 libdispatch.dylib 0x32515f0f4 <redacted>
15 libdispatch.dylib 0x32516dec0 <redacted>
16 libdispatch.dylib 0x32516e6c4 <redacted>
17 libsystem_pthread.dylib 0x42ac9b644 _pthread_wqthread
Thread 2
...
<More 82 threads like Thread 1, all starting with RNMBXImageQueueOperation.start (RNMBXImageQueue.swift:72) and crashing on RCTImageFromLocalAssetURL (RCTUtils.m:864)>
Expected behavior
App not crashing randomly
Notes / preliminary analysis
The traces shows Mapbox running 82 threads of image loading.
Randomly, some thread crash, starting on this call:
RNMBXImageQueueOperation.start (RNMBXImageQueue.swift:72)
and crashing on this call
RCTImageFromLocalAssetURL (RCTUtils.m:864)
Those crashs are rare (2 per day on a production app with 5000 users) and is very possible it is a race condition.
Additional links and references
No response
Reacted by Mathieu Castets, Mathias Lachot and Seth Archambault
Activity
[-][Bug]: Random crashes on iOS, probably because of race condition[/-][+][Bug]: Random crashes on iOS when using local ZXY tiles[/+]mcastets commentedon Mar 19, 2025
Hi, I'm experiencing the same issue.
About 5 crashes per day on a production app with 5k daily users.
A few differences though:
Hope this helps.
Mathiaslachot commentedon Apr 28, 2025
Hello, I’m experiencing the same crash too.
*** error for object %p: pointer being freed was not allocated > mobile > mobile(23538,0x16ba4f000) malloc: *** error for object 0x112cf7620: pointer being freed was not allocatedMy setup:
@rnmapbox/maps: 10.1.38
react-native: 0.76.9
It happens in production for about 2% of our users.
w8ight commentedon Aug 28, 2025
Experiencing the same quite a while
yliu342 commentedon Oct 14, 2025
Not sure if anyone got a fix on this but I was searching around and noticed there is a bug posed in the RN github as well react/react-native#54015. Looking at the stack trace I wasn't really sure what is actually being freed. It was only reproducible on a release build since the crash happened on
RCTBundleAssetImageLoader. On debug this loader is not being usedmfazekas commentedon Oct 14, 2025
This code is not thread safe:
https://github.com/facebook/react-native/blob/6d7a93f2b15dd275a4622625aef089e934a1a8dd/packages/react-native/React/Base/RCTUtils.mm#L853-L872
But RCTImageLoader is, so this seems to be a similar race condition to react/react-native#46115
yliu342 commentedon Oct 14, 2025
Interesting, the code you referenced point to
bundleForPathjust doing some debugging, I'm loading an image with url looks something like thisMyApp.app/assets/application/modules/mapping/assets/Icon.png. Based on the crash report the method that crashed isRCTImageFromLocalAssetURL. With my code, thebundleForPathmethod never gets called.mfazekas commentedon Oct 14, 2025
@yliu342 yes good point.
https://github.com/facebook/react-native/blob/v0.76.0/packages/react-native/React/Base/RCTUtils.m#L864 which in in the original stack trace is also
[UIImage imageNamed:imageName]but it's documented to be thread safe, since ios9:https://developer.apple.com/documentation/uikit/uiimage/init(named:)?language=objc
yliu342 commentedon Oct 14, 2025
Do you mean react/react-native#46115 ticket? Looking closely at this,
One crash I was able to reproduce with reproduce isandCustomer is observing a different crashare two different crash. The one you are experiencing is looping through an array and while looping through it the array got changed. thecustomerone is what being reported here and what we are experiencing.RN has put a lock on the setup to ensure the dispatch queue can't get modified while running the
setupfunction which fixes your issue but I believe it is different from the one in here.yliu342 commentedon Oct 14, 2025
Yes the apple doc does say it is thread safe and I'm 100% agree since my background is writing native iOS code. My guess at this point is something along device running out of memory. If device is under memory pressure and then calling
[UIImage imageNamed:imageName]then there might be some issue with the cache that comes with[UIImage imageNamed:imageName]method?konstmar-ion commentedon Dec 10, 2025
I think we just had a similar crash on app start.
Stacktrace:
mathiasDayuse commentedon Jun 19, 2026
Any news on this? Still happening for us in production.
Update from my side — we've since upgraded our stack and the crash persists:
@rnmapbox/maps: 10.3.1 (latest published)require('...png')marker images via<Images>for aSymbolLayer(clustered search map).Fresh Crashlytics trace —
SIGABRTin libmalloc (pointer being freed was not allocated), originating fromRNMBXImageQueueOperation.start()→RCTImageFromLocalAssetURL→[UIImage imageNamed:]→ CoreUI'sCUICatalog lookupCache/NSCache setName::The crash happens on
com.apple.root.default-qos(theDispatchQueue.global(qos: .default)inRNMBXImageQueue.swift), while loading bundled marker images throughRCTImageLoader. Let me know if there's anyadditional data I can provide to help track this down.
mfazekas commentedon Jun 20, 2026
After investigating these crashes, this is a confirmed upstream bug in
RCTImageLoader— not in rnmapbox/maps itself.Root cause:
RCTImageLoader.imageURLLoaderForURL:has a broken double-checked lock on its_loadersivar, andimageDataDecoderForData:has no synchronization on_decodersat all. Both ivars are strong ARCNSArrays. The Clang ARC spec explicitly states that__strongivar loads/stores are not atomic — so a concurrent read while another thread is writing can observe a half-released object.RNMBXImageQueueOperationsubmits many concurrent image loads, each calling intoRCTImageLoaderfrom a GCD worker thread. On the very first call these threads race through the unguarded init path, one thread releases the intermediate array while another is iterating it, and the over-released object crashes (sometimes immediately inobjc_release/_os_object_release, sometimes later when a GCD autorelease pool drains, sometimes deep in UIKit when the corrupted loader is used for the actual image fetch).Confirming evidence: issue #3589 shows the crash directly inside
imageURLLoaderForURL:at line 182 with_os_object_releaseat the top of the stack — that's the for-loop iterating_loaderswithout a lock while a concurrent thread releases the old array. The crashes in this issue (#3725) follow the same call chain but crash one level deeper (insideRCTBundleAssetImageLoader/UIImage imageNamed:/ CoreUI) becauseimageURLLoaderForURL:returned a dangling loader that was then used for the actual load.Upstream tracking:
setUp()race fixed in [iOS] Fixes race condition when setup image loader react/react-native#46153): fix(image): fix data race in imageURLLoaderForURL: and imageDataDecoderForData: react/react-native#57297Until that lands and is shipped in a React Native release, the workaround is to pre-warm
RCTImageLoaderon the main thread before any concurrent image loads begin — that forces_loaders/_decodersto be initialized synchronously, so later concurrent calls hit the already-initialized fast path safely.