Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Adds thread safe access to MGLNetworkConfiguration events dictionary #15113

Merged
merged 4 commits into from
Jul 16, 2019

Conversation

julianrex
Copy link
Contributor

@julianrex julianrex commented Jul 12, 2019

Fixes #14982, and replaces #15029 in @fabian-guerra's absence.

EDIT: #14982 is a crash in -[MGLNetworkConfiguration startDownloadEvent:type:] caused because NSMutableDictionary is not thread-safe and we have concurrent read/writes. This PR uses a concurrent dispatch queue (to allow concurrent reads) but with dispatch_barrier_async to ensure that writes/deletes are synchronous.

Using GCD is a common solution, though we will need to monitor performance.

/cc @chloekraw

@julianrex julianrex added the iOS Mapbox Maps SDK for iOS label Jul 12, 2019
@julianrex julianrex added this to the release-picklejuice milestone Jul 12, 2019
@julianrex julianrex marked this pull request as ready for review July 12, 2019 16:01
@julianrex julianrex requested a review from 1ec5 as a code owner July 12, 2019 16:01
@julianrex julianrex requested a review from a team July 12, 2019 16:01
@julianrex julianrex requested review from friedbunny and removed request for 1ec5 July 12, 2019 16:05
@friedbunny
Copy link
Contributor

@julianrex for posterity, could you please write up what the original issue was and how this fixes it?

Copy link
Contributor

@friedbunny friedbunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and we should merge this, but I remain confused about why this metrics work isn’t conditional based on whether or not there’s a delegate to consume it. If that had been the case in the initial implementation, this would never have crashed production end-users.

platform/darwin/src/MGLNetworkConfiguration.m Outdated Show resolved Hide resolved
platform/ios/CHANGELOG.md Show resolved Hide resolved
@julianrex julianrex force-pushed the jrex/14982-start-download-event branch from 1bff49b to 228e402 Compare July 15, 2019 18:46
@julianrex
Copy link
Contributor Author

@friedbunny mind taking a another quick look? The delegate method is now called on the main queue, which is wasn't before hand.

@julianrex julianrex merged commit 3c488e0 into master Jul 16, 2019
@julianrex julianrex deleted the jrex/14982-start-download-event branch July 16, 2019 01:11
@chloekraw chloekraw added needs backport Indicates PR needs to be cherrypicked into a previous release branch. crash labels Jul 18, 2019
julianrex pushed a commit that referenced this pull request Jul 24, 2019
julianrex pushed a commit that referenced this pull request Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS needs backport Indicates PR needs to be cherrypicked into a previous release branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in -[MGLNetworkConfiguration startDownloadEvent:type:]
3 participants