fusedLocationClientHandlerThread leaks when DeviceLocationProvider is restarted while stopping (Google Play services provider)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Start by tracing stop and restart handling in GoogleDeviceLocationProvider, especially doStop() and creation or cleanup of fusedLocationClientHandlerThread; compare it with AndroidDeviceLocationProvider and the cited state transition logs. Add or run a regression check for restarting while STOPPING and verify repeated cycles keep the fused location thread count constant.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- Android OS version: Android 14 (API 34), emulator
sdk_gphone64_arm64with Google Play services 23.18.18 - Devices affected: any using the Google Play services location provider (reported on real devices in rnmapbox/maps#4225)
- Maps SDK Version: 11.33.0 (Common 24.33.0), also 11.23.1;
com.google.android.gms:play-services-location:21.3.0
Observed behavior and steps to reproduce
When the shared DeviceLocationProvider is stopped and started again before the stop completes, GoogleDeviceLocationProvider creates a new fusedLocationClientHandlerThread and never quits the previous one. Each such cycle leaks one thread for the lifetime of the process.
Smallest sequence (no MapView needed), on the main thread:
val provider = LocationServiceFactory.getOrCreate().getDeviceLocationProvider(null).value!!
val observer = LocationObserver { }
provider.addLocationObserver(observer)
// later, repeated every 1.5s:
provider.removeLocationObserver(observer) // last observer -> stop, state STOPPING
provider.addLocationObserver(observer) // start while STOPPING
The same happens with the location component plugin, because all MapViews' default location providers share that device provider: with two MapViews, mapA.location.enabled = false; mapB.location.enabled = true in the same frame leaks one thread per toggle.
Debug log for each cycle:
[common\DeviceLocationProvider]: Stop called for GoogleDeviceLocationProvider(1784554533): [request: null] state=STARTED
[common\GoogleDeviceLocationProvider]: doStop() called with currentMode=CALLBACK currentState=STOPPING
[common\DeviceLocationProvider]: Start called for GoogleDeviceLocationProvider(1784554533): [request: null], state=STOPPING
[common\GoogleDeviceLocationProvider]: Location cancellation succeeded state=STARTING currentMode=CALLBACK
[common\GoogleDeviceLocationProvider]: Skipped stop state change: current state is STARTING
[common\GoogleDeviceLocationProvider]: Location request succeeded state=STARTING currentMode=CALLBACK
[common\GoogleDeviceLocationProvider]: Started location updates with mode CALLBACK
fusedLocation* threads (adb shell ps -T -p <pid> | grep -c fusedLocation) before / after 30 cycles:
| Sequence | 11.33.0 | 11.23.1 |
|---|---|---|
| remove + add observer back-to-back | 3 → 33 | 2 → 32 |
| two MapViews, puck off/on in the same frame | 3 → 33 | 2 → 32 |
| remove, add 1s later (control) | 3 → 3 | 2 → 2 |
| two MapViews, enable 1s after disable (control) | 3 → 3 | – |
either sequence without play-services-location (AndroidDeviceLocationProvider) |
0 → 0 | – |
Full repro project (single activity, token placeholder): https://gist.github.com/mfazekas/dc134449120dcf45876eb1d7592dbe6d
Expected behavior
Restarting the provider while it is stopping reuses the existing handler thread, or quits the old one, so the thread count stays constant.
Notes / preliminary analysis
The pending stop's completion sees state STARTING and skips the state change ("Skipped stop state change"), and the old fusedLocationClientHandlerThread is never quit while the start creates a new one. The platform provider doesn't leak. Over a long session (e.g. navigating between screens that each show a map with a location puck) this grows by one thread and its native resources per transition.
Additional links and references
Found via @rnmapbox/maps: https://github.com/rnmapbox/maps/issues/4225 (workaround in https://github.com/rnmapbox/maps/pull/4397).
- Ngôn ngữ chính
- Kotlin
- Star
- 584
- Fork
- 167
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của mapbox/mapbox-maps-android
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 44/100
mapbox/mapbox-maps-android#2737 ·
-
bug :beetle:
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
mapbox/mapbox-maps-android#2736 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
mapbox/mapbox-maps-android#2733 · 1 reaction ·
-
Pins Flicker During Zoom OutĐang mởbug :beetle:
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
mapbox/mapbox-maps-android#2732 ·
-
[R8] Maps and Search SDK consumer rules apply app-wide and significantly restrict optimizationĐang mởauto-triaged bug :beetle:
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
mapbox/mapbox-maps-android#2731 · 8 reaction ·
Tất cả issue của mapbox/mapbox-maps-android
Issue tương tự
-
[BUG] Issue reported from ReFraĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
IacobIonut01/ReFra#1515 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
openwatersio/slackwater-android#162 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
developmentwithyash/yaan#184 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
analytics
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
🐛 Type:Bug 📏 Size: S 🔧 State:In Progress 🔹 Priority: P2 - Medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
yeliqin666/xjtu-toolbox-android#623 · 1 bình luận ·