Bug 1774918: Consolidate accessibility mutation events in fewer IPC messages, r=Jamie,geckoview-reviewers,m_kato
This revision modifies the way that ProcessMutationEvents works. Rather than firing mutation events immediately, it instead causes them to be queued on DocAccessibleChild via HandleAccEvent. The code then fires the events in batches with a new IPC method, SendMutationEvents. The net effect of this change is a significant reduction in pressure on the IPC system, in favor of fewer, larger messages. For pages that generate many mutation events often, this represents a big win for performance. Without this, the IPC queue can get backed up, failing to keep up with the amount of accessibility IPC messages as they flood in. The method of batching is carefully written to maximize the amount of accessibles that can be touched in a mutation event batch without going over the IPC message size limit. This revision does not implement size tracking, but does make a reasonable approximation. With these changes, heterogenous mutation event types can sit together in batches, including sub-batches of show events. A side effect of this change is that initial page load is further amalgamated; multiple document children that produce separate calls to InsertIntoIpcTree now use this queueing mechanism and can have their show events sent together. Some messages may fire differently from their former ordering with this change, particularly EVENT_MENUPOPUP_END for content processes. However, that event appears to have been fired out of order with the existing code, meaning that this change represents a fix to that ordering issue as well. Finally, this revision makes a slight modification to an Android test for clarity and correctness. I discovered this issue while debugging event ordering and realized it was valuable to fix. Differential Revision: https://phabricator.services.mozilla.com/D229842
This commit is contained in:
@@ -1007,6 +1007,12 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
|
||||
CoalesceMutationEvents();
|
||||
ProcessMutationEvents();
|
||||
|
||||
// ProcessMutationEvents for content process documents merely queues mutation
|
||||
// events. Send those events in a batch now if applicable.
|
||||
if (mDocument && mDocument->IPCDoc()) {
|
||||
mDocument->IPCDoc()->SendQueuedMutationEvents();
|
||||
}
|
||||
|
||||
// When firing mutation events, mObservingState is set to
|
||||
// eRefreshProcessing. Any calls to ScheduleProcessing() that
|
||||
// occur before mObservingState is reset will be dropped because we only
|
||||
@@ -1028,6 +1034,13 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
|
||||
|
||||
ProcessEventQueue();
|
||||
|
||||
// There should not be any more mutation events in the mutation event queue.
|
||||
// ProcessEventQueue should have sent all of them.
|
||||
if (mDocument && mDocument->IPCDoc()) {
|
||||
MOZ_ASSERT(mDocument->IPCDoc()->MutationEventQueueLength() == 0,
|
||||
"Mutation event queue is non-empty.");
|
||||
}
|
||||
|
||||
if (IPCAccessibilityActive()) {
|
||||
size_t newDocCount = newChildDocs.Length();
|
||||
for (size_t i = 0; i < newDocCount; i++) {
|
||||
|
||||
Reference in New Issue
Block a user