Repository navigation
Implement hardResetDatabase method - #2
orca-nazar wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements the hardResetDatabase method to provide a comprehensive reset of the Mapbox offline database. The implementation handles platform differences: iOS deletes both .mapbox/map_data and .mapbox_custom directories and reinitializes the OfflineRegionManager with a fresh custom directory, while Android simply deletes the .mapbox/map_data directory and relies on the C++ manager to auto-recreate the database.
- Adds
hardResetDatabase()method across TypeScript, iOS, and Android implementations - Updates iOS MapView and OfflineRegionManager initialization to support custom data path resolution
- Implements platform-specific cleanup strategies (iOS: full reset with reinitialization, Android: directory deletion only)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/modules/offline/offlineManagerLegacy.ts |
Adds hardResetDatabase() method with detailed documentation explaining platform differences |
ios/RNMBX/RNMBXMapView.swift |
Adds data path resolution logic to prefer .mapbox_custom directories over default .mapbox/map_data |
ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift |
Implements hardResetDatabase() and reinitOfflineRegionManager() with custom data path resolution; updates offlineRegionManager lazy property to support custom paths |
ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.m |
Exposes hardResetDatabase method to React Native bridge |
android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXOfflineModuleLegacy.kt |
Implements hardResetDatabase() to delete .mapbox/map_data directory on a background thread |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
cleanest setup:
i think you might have mentioned that above flow doesn't work. looking at the code, don't see why this is not possible. i'd use the same approach on both platforms. |
Almost the same approach was tested on iOS, but it doesn’t work. “Almost” because there is no way to unmount the offline manager on the Swift side (unless you’ve found a workaround?). We also thought this approach would work well on Android. Partially, yes: I ran several test iterations in debug with different offline data sizes (0.1–2.5 GB), and initially tested small sizes in production. No issues were noticed. However, after testing the deletion of a 2.5 GB dataset in production, the simpler approach failed. It turned out that this approach is not reliable for larger databases. To summarize, iOS and Android now follow the same hard reset flow, which is robust and validated for databases up to 2.5 GB. We will run one more iteration with a 4.5 GB database, as one user attempted to update/delete approximately that amount of data. |
|
Test result 1. Deleting ~4.6GB on iOS passed |
|
alternative unmount map view -> reinint offline manager -> destroy old db -> mount map view |
good work. i'm happy with this. i just felt it could be cleaner. |
|
No need anymore. Hard reset could be done fully from JS side by usign this flow |
|
This approach doesn't work anymore in mapbox 11.26.0 |
Description
Added hardResetDatabase that includes 2 steps:
.mapbox_custom. To force Mapbox recreate a new database in a new folder. Otherwise, recreation doesn't work