base: MessagePumpAndroid - don't double non-delayed callback on sleep
There was no advantage to this way of doing things. Android does not
round-robin native tasks and application tasks (it batches all native
messages, then all callbacks (in one PollOnce call), then in as many
subsequent PollOnce calls as there are user-defined non-callback fds,
one of those per PollOnce() (though these are not present in the pump)),
and so it is opaque to us at any point whether the pump is idle or not
- by the time a ScheduleWork() with do_idle_work roundtrip is done,
there could be or not be an arbitrary amount of work to do on the
native side.
Since there is a great cost associated with the do_idle_work
ScheduleWork() roundtrip with no visible gain, remove this and instead
go to sleep immediately (calling DoIdleWork()) every time the pump
returns expecting to poll.
We had considered calling ALooper_PollOnce() from the callback to
determine whether it was idle for ourselves, but it appears that the
function is not reentrant.
Bug: 40226913, 41482601
Change-Id: I4e43ee0032bb50b81a0f50bfc7498546ba47ae58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5479431
Commit-Queue: Sean Maher <[email protected]>
Reviewed-by: Olivier Li <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1302048}
diff --git a/base/task/task_features.cc b/base/task/task_features.cc
index 2ec6a7a..3b827c9 100644
--- a/base/task/task_features.cc
+++ b/base/task/task_features.cc
@@ -55,6 +55,10 @@
BASE_FEATURE(kUIPumpImprovementsWin,
"UIPumpImprovementsWin",
+ base::FEATURE_ENABLED_BY_DEFAULT);
+
+BASE_FEATURE(kPumpFastToSleepAndroid,
+ "PumpFastToSleepAndroid",
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kRunTasksByBatches,