react-native-google-maps-plus 1.8.4 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ import MarkerTag
5
5
  import PolygonTag
6
6
  import PolylineTag
7
7
  import android.annotation.SuppressLint
8
+ import android.content.ComponentCallbacks2
9
+ import android.content.res.Configuration
8
10
  import android.graphics.Bitmap
9
11
  import android.location.Location
10
12
  import android.util.Size
@@ -105,8 +107,24 @@ class GoogleMapsViewImpl(
105
107
 
106
108
  private var cameraMoveReason = -1
107
109
 
110
+ val componentCallbacks =
111
+ object : ComponentCallbacks2 {
112
+ override fun onConfigurationChanged(newConfig: Configuration) {}
113
+
114
+ override fun onLowMemory() {
115
+ mapView?.onLowMemory()
116
+ markerBuilder.clearIconCache()
117
+ }
118
+
119
+ override fun onTrimMemory(level: Int) {
120
+ mapView?.onLowMemory()
121
+ markerBuilder.cancelAllJobs()
122
+ }
123
+ }
124
+
108
125
  init {
109
126
  MapsInitializer.initialize(reactContext)
127
+ reactContext.registerComponentCallbacks(componentCallbacks)
110
128
  reactContext.addLifecycleEventListener(this)
111
129
  }
112
130
 
@@ -822,6 +840,7 @@ class GoogleMapsViewImpl(
822
840
  removeAllViews()
823
841
  }
824
842
  super.removeAllViews()
843
+ reactContext.unregisterComponentCallbacks(componentCallbacks)
825
844
  reactContext.removeLifecycleEventListener(this)
826
845
  initialized = false
827
846
  }
@@ -45,7 +45,7 @@ class MapMarkerBuilder(
45
45
  private val scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default),
46
46
  ) {
47
47
  private val iconCache =
48
- object : LruCache<Int, BitmapDescriptor>(512) {
48
+ object : LruCache<Int, BitmapDescriptor>(256) {
49
49
  override fun sizeOf(
50
50
  key: Int,
51
51
  value: BitmapDescriptor,
@@ -281,7 +281,7 @@ class MapMarkerBuilder(
281
281
  onReady(desc)
282
282
  }
283
283
  } catch (_: OutOfMemoryError) {
284
- iconCache.evictAll()
284
+ clearIconCache()
285
285
  withContext(Dispatchers.Main) {
286
286
  ensureActive()
287
287
  onReady(null)
@@ -310,6 +310,10 @@ class MapMarkerBuilder(
310
310
  jobsById[id]?.cancel()
311
311
  }
312
312
  jobsById.clear()
313
+ clearIconCache()
314
+ }
315
+
316
+ fun clearIconCache() {
313
317
  iconCache.evictAll()
314
318
  }
315
319
 
@@ -42,19 +42,39 @@ GMSIndoorDisplayDelegate {
42
42
  setupAppLifecycleObservers()
43
43
  }
44
44
 
45
+ @MainActor
46
+ private var lifecycleTasks = [Task<Void, Never>]()
47
+
45
48
  @MainActor
46
49
  private func setupAppLifecycleObservers() {
47
- NotificationCenter.default.addObserver(
48
- self,
49
- selector: #selector(appDidBecomeActive),
50
- name: UIApplication.didBecomeActiveNotification,
51
- object: nil
50
+ lifecycleTasks.append(
51
+ Task { @MainActor in
52
+ for await _ in NotificationCenter.default.notifications(
53
+ named: UIApplication.didBecomeActiveNotification
54
+ ) {
55
+ appDidBecomeActive()
56
+ }
57
+ }
58
+ )
59
+
60
+ lifecycleTasks.append(
61
+ Task { @MainActor in
62
+ for await _ in NotificationCenter.default.notifications(
63
+ named: UIApplication.didEnterBackgroundNotification
64
+ ) {
65
+ appDidEnterBackground()
66
+ }
67
+ }
52
68
  )
53
- NotificationCenter.default.addObserver(
54
- self,
55
- selector: #selector(appDidEnterBackground),
56
- name: UIApplication.didEnterBackgroundNotification,
57
- object: nil
69
+
70
+ lifecycleTasks.append(
71
+ Task { @MainActor in
72
+ for await _ in NotificationCenter.default.notifications(
73
+ named: UIApplication.didReceiveMemoryWarningNotification
74
+ ) {
75
+ onLowMemory()
76
+ }
77
+ }
58
78
  )
59
79
  }
60
80
 
@@ -688,16 +708,20 @@ GMSIndoorDisplayDelegate {
688
708
  }
689
709
  }
690
710
 
691
- @objc private func appDidBecomeActive() {
711
+ private func appDidBecomeActive() {
692
712
  if window != nil {
693
713
  locationHandler.start()
694
714
  }
695
715
  }
696
716
 
697
- @objc private func appDidEnterBackground() {
717
+ private func appDidEnterBackground() {
698
718
  locationHandler.stop()
699
719
  }
700
720
 
721
+ private func onLowMemory() {
722
+ markerBuilder.cancelAllIconTasks()
723
+ }
724
+
701
725
  override func didMoveToWindow() {
702
726
  super.didMoveToWindow()
703
727
  if window != nil {
@@ -708,8 +732,9 @@ GMSIndoorDisplayDelegate {
708
732
  }
709
733
 
710
734
  deinit {
711
- NotificationCenter.default.removeObserver(self)
712
735
  deinitInternal()
736
+ lifecycleTasks.forEach { $0.cancel() }
737
+ lifecycleTasks.removeAll()
713
738
  }
714
739
 
715
740
  func mapViewDidFinishTileRendering(_ mapView: GMSMapView) {
@@ -5,7 +5,7 @@ import UIKit
5
5
  final class MapMarkerBuilder {
6
6
  private let iconCache: NSCache<NSNumber, UIImage> = {
7
7
  let c = NSCache<NSNumber, UIImage>()
8
- c.countLimit = 512
8
+ c.countLimit = 256
9
9
  return c
10
10
  }()
11
11
  private var tasks: [String: Task<Void, Never>] = [:]
@@ -205,6 +205,7 @@ final class MapMarkerBuilder {
205
205
  }
206
206
  tasks.removeAll()
207
207
  iconCache.removeAllObjects()
208
+ CATransaction.flush()
208
209
  }
209
210
 
210
211
  @MainActor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-maps-plus",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "description": "React Native wrapper for Android & iOS Google Maps SDK",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -80,9 +80,9 @@
80
80
  "devDependencies": {
81
81
  "@commitlint/cli": "20.1.0",
82
82
  "@commitlint/config-conventional": "20.0.0",
83
- "@eslint/compat": "1.4.0",
83
+ "@eslint/compat": "1.4.1",
84
84
  "@eslint/eslintrc": "3.3.1",
85
- "@eslint/js": "9.38.0",
85
+ "@eslint/js": "9.39.1",
86
86
  "@expo/config-plugins": "54.0.2",
87
87
  "@jamesacarr/eslint-formatter-github-actions": "0.2.0",
88
88
  "@react-native/babel-preset": "0.82.1",
@@ -95,17 +95,17 @@
95
95
  "clang-format-node": "2.0.3",
96
96
  "conventional-changelog-conventionalcommits": "9.1.0",
97
97
  "del-cli": "7.0.0",
98
- "eslint": "9.38.0",
98
+ "eslint": "9.39.1",
99
99
  "eslint-config-prettier": "10.1.8",
100
100
  "eslint-plugin-ft-flow": "3.0.11",
101
101
  "eslint-plugin-prettier": "5.5.4",
102
102
  "jest": "30.2.0",
103
- "lefthook": "2.0.0",
103
+ "lefthook": "2.0.2",
104
104
  "nitrogen": "0.30.2",
105
105
  "prettier": "3.6.2",
106
106
  "react": "19.1.1",
107
107
  "react-native": "0.82.1",
108
- "react-native-builder-bob": "0.40.13",
108
+ "react-native-builder-bob": "0.40.14",
109
109
  "react-native-nitro-modules": "0.30.2",
110
110
  "semantic-release": "25.0.1",
111
111
  "typescript": "5.9.3"