mapbox / mapbox/mapbox-maps-ios
Snapshotter can start returning duplicate snapshots after heavy use
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
Environment
- Xcode version: 16.4 (16F6)
- iOS version: 18.5 (22F76)
- Devices affected: observed in simulator and on HW (iPhone 15 Pro Max)
- Maps SDK Version: 11.12.1
Observed behavior and steps to reproduce
I have an app that can generate thousands of snapshots. Sometimes the Snapshotter gets into a state where it will return the same snapshot for every call.
Expected behavior
The correct snapshot every time :-)
Notes / preliminary analysis
I can only reproduce this sporadically, so I suspect that a race condition can lead to some kind of internal state corruption. When it is in this state, the camera will be pointing to the correct location (in the completion callback), but the snapshot is for the old location. The overlay callback is called still so it's some layer of caching before that.
I am detecting duplicates by generating a SHA256 hash of the HEIC data for the snapshots, and then checking for duplicate hashes. I have allowlisted hashes from a half dozen solid color images as these are valid duplicates.
Calling cancel before start does not prevent the issue (I serialize requests externally and have verified that that is working so I would not expect cancel to help).
Setting the snapshotSize to some other size and then back again DOES appear to work around the issue, e.g.:
snapshotter.snapshotSize = CGSize(width: 258, height: 258)
snapshotter.snapshotSize = CGSize(width: 256, height: 256)
Merely setting it to the same value does not impact things presumably because you're checking for that :-).
I have also seen the Snapshotter begin to produce completely transparent snapshots after experiencing this initial duplicate behavior.
Additional links and references
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing repeated Snapshotter requests under the reported iOS and Maps SDK versions, then inspect the Snapshotter behavior around repeated calls and snapshotSize changes. Compare returned image data with the requested camera location and check whether the duplicate and transparent outputs can be prevented; the issue is done when sustained use returns the correct snapshot each time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100