-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
In #3833 the _flutter.listViews RPC moved from thread based to lock based synchronization. The thread based synchronization side effect was used by flutter benchmarks in https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/vmservice.dart#L1223 and https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/run_hot.dart#L156 to ensure the completeness of the restart/reload and so correct timing. A new RPC _flutter.waitUIThreadIdle is introduced to allow the flutter benchmarks to reintroduce thread based synchronization. Related flutter/flutter#11241
const char** param_values, | ||
intptr_t num_params, | ||
void* user_data, | ||
const char** json_object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation seems off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -314,4 +316,29 @@ void PlatformViewServiceProtocol::ScreenshotGpuTask(SkBitmap* bitmap) { | |||
canvas->flush(); | |||
} | |||
|
|||
const char* PlatformViewServiceProtocol::kWaitUIThreadIdleExtensionName = | |||
"_flutter.waitUIThreadIdle"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking this is not waiting for the UI thread to idle it is more wait for UI thread to finish processing the first event, I don't have a better name for it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about FlushUIThreadTasks
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not actually flushing all the tasks, but just the first one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? The implementation calls blink::Threads::UI()->PostTask
, which will queue up a task. Given that the message queue is FIFO, all tasks that were scheduled prior to this task will execute first. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misunderstood the meaning of Tasks, you are right. It will wait for all the previous tasks to be flushed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Added @jason-simmons to reviewer list for C++/engine readability. |
|
||
// This API should not be invoked by production code. | ||
// It can potentially starve the service isolate if the main isolate pauses | ||
// at a breakpoint or is in an infinite loop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth mentioning that this method must be invoked from the VM service thread and blocks it until UI thread tasks are processed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add this description even to the other services? some of them are blocking too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great. We have comments like that in shell.h
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -314,4 +316,29 @@ void PlatformViewServiceProtocol::ScreenshotGpuTask(SkBitmap* bitmap) { | |||
canvas->flush(); | |||
} | |||
|
|||
const char* PlatformViewServiceProtocol::kWaitUIThreadIdleExtensionName = | |||
"_flutter.waitUIThreadIdle"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about FlushUIThreadTasks
?
@@ -43,6 +43,17 @@ class PlatformViewServiceProtocol { | |||
void* user_data, | |||
const char** json_object); | |||
static void ScreenshotGpuTask(SkBitmap* bitmap); | |||
|
|||
// This API should not be invoked by production code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto re calling from VM isolate thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
So if I understand correctly, the claim here is that hot_mode_dev_cycle__benchmark hotRestartMillisecondsToFrame used to count the entire cycle of "wait for UI thread to be stable, tell app to restart, then wait for app to be done", and now it only counts "tell app to restart, then wait for app to be done"? Similarly, is the claim that hot_mode_dev_cycle__benchmark hotReloadMillisecondsToFrame used to not count the time waiting for the app to be stable before triggering the hot reload, but now that it does include that time, the reload takes two SECONDS more? I find it surprising that both of these benchmarks imply that the app is locked for two seconds every time, reliably. There's very little noise in how much difference the benchmarks are seeing. |
@Hixie
while hot_mode_dev_cycle__benchmark hotReloadMillisecondsToFrame used to count:
Now instead hot_mode_dev_cycle__benchmark hotRestartMillisecondsToFrame counts:
while hot_mode_dev_cycle__benchmark hotReloadMillisecondsToFrame counts:
We are actually counting a part of hotRestartMillisecondsToFrame inside hotReloadMillisecondsToFrame instead. |
That implies that it takes ~2500 milliseconds for an app to start ("wait for the app to be done / wait for UI thread to be empty"), and ~2000ms for an idle app to be ready to be hot reloaded, both of which seems exceedingly high. |
On my device we can see this:
It takes:
|
Changes introduced in flutter/engine@8ba522e has removed from the `_flutter.listViews` the thread synchronization side effect used during benchmarks. The thread synchronization is restored via the new `_flutter.flushUIThreadTasks` RPC. Fixes #11241 Related flutter/engine#3898
In #3833 the
_flutter.listViews
RPC moved from thread based to lock based synchronization.The thread based synchronization side effect was used by flutter benchmarks in https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/vmservice.dart#L1223 and
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/run_hot.dart#L156 to ensure the completeness of the restart/reload and so correct timing.
A new RPC
_flutter.flushUIThreadTasks
is introduced to allow the flutter benchmarks to reintroduce thread based synchronization.Related flutter/flutter#11241