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

[not ready] Make Annotations API threadsafe - #1022

Merged
incanus merged 4 commits into
masterfrom
1022-annotations-thread-safety
Mar 23, 2015
Merged

incanus merged 4 commits into
masterfrom
1022-annotations-thread-safety

Conversation

@kkaefer

@kkaefer kkaefer commented Mar 20, 2015

Copy link
Copy Markdown
Member

This currently reaches into the innards of the Map objects from the main thread, which is not safe.

/cc @incanus

@incanus

incanus commented Mar 18, 2015

Copy link
Copy Markdown
Contributor

Thanks for the flag @kkaefer. I think this will be an easy lift as the Map just serves:

  • As a passthrough from the client to the single AnnotationManager, which expects operations on the main thread
  • As a const argument map.getMaxZoom() for some calculations
  • As a target for map.triggerUpdate(), which can run on any thread

@incanus incanus self-assigned this Mar 18, 2015
@incanus incanus added this to the iOS Beta 1 milestone Mar 18, 2015
@incanus incanus added the bug label Mar 18, 2015
@kkaefer

kkaefer commented Mar 18, 2015

Copy link
Copy Markdown
Member Author

Specifically, updateAnnotationTiles iterates through activeSources, which is Map thread, not main thread.

@incanus

incanus commented Mar 18, 2015

Copy link
Copy Markdown
Contributor

👍 Good call.

@incanus

incanus commented Mar 18, 2015

Copy link
Copy Markdown
Contributor

@kkaefer How close is something like e48b786 to a solution? Right direction? I realize this has some issues (but also could always use them pointed out 😉).

@mb12

mb12 commented Mar 18, 2015

Copy link
Copy Markdown

@incanus One option to avoid uv_async::send would be to expose an interface similar to NSObject.performSelectorOnMainThread in mbgl::Map class. This would allow such code to be added without any changes to the Map class.

@incanus

incanus commented Mar 18, 2015

Copy link
Copy Markdown
Contributor

I was chatting about that very approach with @kkaefer; we may get there eventually.

@incanus

incanus commented Mar 19, 2015

Copy link
Copy Markdown
Contributor

@kkaefer will be taking a look at shoring this up.

@incanus incanus assigned kkaefer and unassigned incanus Mar 19, 2015
@kkaefer

kkaefer commented Mar 20, 2015

Copy link
Copy Markdown
Member Author

Note that this change does not yet fix the actual issue of accessing the tile data and source objects from both threads.

@kkaefer

kkaefer commented Mar 20, 2015

Copy link
Copy Markdown
Member Author

@incanus Can we remove the shared pointer use in live_tile.*?

@incanus

incanus commented Mar 20, 2015

Copy link
Copy Markdown
Contributor

We have solid improvements across the board here, but still not a fix for the core threading problem.

@incanus incanus changed the title Make Annotations API threadsafe [not ready] Make Annotations API threadsafe Mar 20, 2015
@incanus

incanus commented Mar 22, 2015

Copy link
Copy Markdown
Contributor

@kkaefer What's your ETA look like for the actual threading fixes here? I think we should get these improvements at they stand now over into master with all the improvements to passing by reference, constness, and the like on the sooner side.

@incanus

incanus commented Mar 23, 2015

Copy link
Copy Markdown
Contributor

Per voice with @kkaefer I'm going to merge these improvements and spin out a new ticket specific to the threading issues, which we don't have a good answer on yet. We are both meditating on this 🙇

@incanus

incanus commented Mar 23, 2015

Copy link
Copy Markdown
Contributor

→ #1069 for the thread work-to-be.

incanus added a commit that referenced this pull request Mar 23, 2015
@incanus
incanus merged commit 77c3862 into master Mar 23, 2015
@incanus
incanus deleted the 1022-annotations-thread-safety branch March 23, 2015 19:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants