Repository navigation
Always drive rendering from the main thread - #1624
Conversation
|
@ljbade from the map thread, how can we signal to the main UI/Java thread that it must call |
|
@kkafer first issue is that you need to attach java runtime to the map thread then you can use JNI to invoke Java. An example is the event handling for the map class in the nativemapview.cpp file. Next issue is that Android does not allow non UI thread to touch UI objects so likely you need to call an async handler that runs on the UI thread. It may be simpler to implement async call in C++ to UI thread |
|
@ljbade so the flow would be:
We can't really do an async call in C++ land since we don't have an event loop running in the Main thread. Essentially, what I'm looking for is a way to trigger a frame update from the Map thread. Do you see any other options? |
|
@kkaefer you can have many threads attached, you just have to remember to detach before deleting the thread Isn't most the Map functions async? Perhaps this can all be done in C++ side by just calling Map. |
|
We should pick this up again, I think it's a dependency for #1026. |
fedef30 to
c531b1c
Compare
|
@jfirebaugh updated and fixed Android support. This is mostly a stopgap for Android to keep the app functional; we need a larger Android refactoring eventually. |
c531b1c to
70a58c1
Compare
70a58c1 to
7734ca0
Compare
There was a problem hiding this comment.
Since render doesn't check mayRender, it seems like it's equivalent to "is a still render pending?". Can we use callback in update() instead, like:
if (callback) {
render();
} else {
view.invalidate();
}
Or is there something I'm missing?
|
I made @incanus, can you review these changes (particularly 8e9a7e9, 9dc0263 and 7549aaf) and test them with the view-syncing stuff you're working on? The remaining fix for |
|
I don't see this affecting what I'm working on, as I'm no longer driving annotation view updates from the notification indirectly, but rather in the same method that the core GL view is told to render a frame synchronously. I will test, though. As for approach, it looks good and tests pass, but I'll take a closer look. |
|
@incanus @jfirebaugh any objections to merging this? |
|
Still got a bit more digging to do — will hit it this am. |
There was a problem hiding this comment.
Please use MGLAssertIsMainThread(), which provides more details in the assertion message.
There was a problem hiding this comment.
On second thought, that won’t work because _cmd is only available inside Objective-C classes. NSCAssert() would still be preferable to assert() in Objective-C code, though.
|
Ok I am 👍 if you are @jfirebaugh — this doesn't interfere with anything I'm working on and it certainly looks cleaner from the will/am/did update notification POV. |
Pass current state to MapContext where needed. Remove mutex from Transform.
7549aaf to
ea5c56d
Compare
|
Great work. Thanks for fixing this. |
In most cases, the main/UI thread triggers rendering, except for our GLFW sample app.