Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Memory leak in CameraAnimatorsRunner (11.31.1)

Aperta
#2,448 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
swift
Ambito
performance

Direzione di ricerca

Start in Sources/MapboxMaps/Camera/CameraAnimatorsRunner.swift: add(_ animator:) appends each onCameraAnimatorStatusChanged subscription to cancelables and nothing prunes them, so entries outlive their animators. Read how AnyCancelable and ClosureHandlersStore interact to find a safe point to drop cancelled subscriptions (the suggested pruning on next add() is one option). Verify with Instruments/leak counts over a simulated navigation run, mimicking the growth of ClosureHandlersStore<CameraAnimatorStatus, ()> described in the report; done means instance counts stay flat over a long run.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

auto-triaged bug :beetle: p2

Versions: mapbox-maps-ios 11.31.1 with mapbox-navigation-ios 3.31.1. CameraAnimatorsRunner.swift on main is byte-for-byte the same as in 11.31.1.

In Sources/MapboxMaps/Camera/CameraAnimatorsRunner.swift, add(_ animator:) stores each animator's onCameraAnimatorStatusChanged subscription in the cancelables set. Nothing ever removes it, so every subscription stays alive until the MapView is deallocated, even after the animator itself has been released. The AnyCancelable returned by ClosureHandlersStore.add(handler:) holds a strong reference to the animator's ClosureHandlersStore and its handler, so each animator leaves behind two NSLocks.

During navigation this grows non-stop. In following mode, NavigationCameraStateTransition.update(to:state:) in the Navigation SDK creates 2-6 new animators on every camera update (zoom and padding are animated even when unchanged), about 5 times a second.

Measured: ClosureHandlersStore<CameraAnimatorStatus, ()> instances grew from 132 to 11,645 over about 2,300 s of simulated driving (about 6 MB). AnyCancelable, ObjectWrapper and NSLock grew at the same rate. There was only one CameraAnimatorsRunner the whole time.

Suggested fix: remove a subscription once its animator has been released, for example by pruning the set on the next add() call. This doesn't change how the camera behaves.

Lingua principale
Swift
Stelle
601
Fork
198
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mapbox/mapbox-maps-ios

Tutte le issue di mapbox/mapbox-maps-ios

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.