|
|
| Line 101: |
Line 101: |
| = Recording Markers in a Different Thread = | | = Recording Markers in a Different Thread = |
|
| |
|
| For now, it's not supported. Only operations in the main thread are instrumented. | | For now, it's not supported. Only operations in the main thread are instrumented. Follow https://bugzilla.mozilla.org/show_bug.cgi?id=1152988 to watch for support for markers from different threads. |
| | |
| '''Notes from Tom:'''
| |
| | |
| First, right now when a marker object is created, it acquires the time
| |
| from the docshell. In docshell/base/TimelineMarker.cpp:
| |
| | |
| TimelineMarker::TimelineMarker(nsDocShell* aDocShell, const char* aName,
| |
| TracingMetadata aMetaData)
| |
| [...]
| |
| aDocShell->Now(&mTime);
| |
| | |
| Now, I think nsDocShell::Now is actually thread-safe. However, I would probably move the logic into TimelineMarker itself and avoid the need to have a docshell at TimelineMarker creation. The code was written this way mostly for historical reasons, but also perhaps to make sure that the timeline epoch is dealt with in a single place.
| |
| | |
| At this point you could make a new TimelineMarker object on any thread.
| |
| | |
| So then the next step is to ship it to the main thread. Basically I'd make a new nsIRunnable that holds the TimelineMarker object, and use NS_DispatchToMainThread. This runnable would call nsDocShell::AddProfileTimelineMarker when it ran.
| |
| | |
| This last step is the trickiest -- you have to pick which docshell to notify. I don't know of a generic way to do this; it's been the trickiest part of the patches I worked on. ('''Note from Paul''': depending on the type of thread, we might register these markers at the global level. For example, it doesn't make sense to attach markers from the compositor thread to a docshell. It's not the case to network threads though).
| |
| | |
| Because we add the start and stop-markers to the docshell separately, it's simple to add a start marker from one thread and an end marker from another thread; or whatever you like.
| |