Repository navigation
Move logging off the main thread - #16325
Conversation
|
What will this mean for platform SDKs that implement observers? /cc @captainbarbosa |
b612466 to
e843aff
Compare
| const optional<std::string>& threadName) { | ||
| std::lock_guard<std::mutex> lock(mutex); | ||
| if (currentObserver && severity != EventSeverity::Debug && | ||
| currentObserver->onRecord(severity, event, code, msg)) { |
There was a problem hiding this comment.
This may be a breaking behavior change. Where thread safety should be implemented? On client side or we need to post currentObserver->onRecord invocation on the thread where setObserver was called?
There was a problem hiding this comment.
What was the outcome of this?
There was a problem hiding this comment.
I like the idea of the developer providing the thread/queue for logging, rather than one being created, but that feels like a possible follow-on?
There was a problem hiding this comment.
This question was more directed to Android and iOS, and both have now confirmed that the log observers are thread safe.
Regarding the developer providing the thread/queue, it can be a possible follow-up in case there's a need for it.
|
@julianrex @tobrun if you use log observers, are they thread safe? |
Android, yes |
alexshalamov
left a comment
There was a problem hiding this comment.
lgtm, maybe worth waiting for feedback from iOS folks
|
agreed, cc @mapbox/maps-ios @1ec5 to review |
|
Is the primary use-case for |
|
Can we merge this after 1.5.0 please? |
@julianrex It's needed for GL native unit tests. Some tests are counting the number of logs to decide pass/fail so the second commit in this PR disables the logging thread for those tests. |
|
Thanks @jmalanen - it would be a good option to make this configurable, especially to the end developer - does this allow for that? |
|
@julianrex It is already configurable. The developer can call |
|
|
@1ec5 @julianrex Can you please review this from iOS point of view? |
some tests are counting the number of logs to determine pass/fail so disable separate logging thread for them.
|
|
||
| FixtureLog::FixtureLog() : observer(new FixtureLogObserver(this)) { | ||
| Log::setObserver(std::unique_ptr<Log::Observer>(observer)); | ||
| Log::useLogThread(false); |
There was a problem hiding this comment.
Is there a test where useThread is true?
There was a problem hiding this comment.
All other tests that don't count the number of log messages have useThread == true
|
Looks good from an iOS pov - our default logging observer is thread-safe. A few questions, but shouldn't block this PR:
|
@julianrex Thank you for the review! Merging the PR based on this.
No.
The thread where the log was initiated.
I am currently not aware of such use cases, but it could be another follow-up feature in case there's a need for that. |
Fixes: mapbox/mapbox-gl-native-team/issues/224