Skip to content

Commit 43ee40e

Browse files
Engine startup event timed after VM initializes (flutter#35713)
* Engine startup event timed after VM initializes * Formatting * Update FlutterEngineMainEnter event comment * Remove engine_start_time * Remove unused variable
1 parent 7a40a0a commit 43ee40e

4 files changed

Lines changed: 13 additions & 27 deletions

File tree

common/settings.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,6 @@ struct Settings {
301301
// Max bytes threshold of resource cache, or 0 for unlimited.
302302
size_t resource_cache_max_bytes_threshold = 0;
303303

304-
/// A timestamp representing when the engine started. The value is based
305-
/// on the clock used by the Dart timeline APIs. This timestamp is used
306-
/// to log a timeline event that tracks the latency of engine startup.
307-
std::chrono::microseconds engine_start_timestamp = {};
308-
309304
/// The minimum number of samples to require in multipsampled anti-aliasing.
310305
///
311306
/// Setting this value to 0 or 1 disables MSAA.

runtime/dart_vm.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -467,19 +467,19 @@ DartVM::DartVM(std::shared_ptr<const DartVMData> vm_data,
467467
// Send the earliest available timestamp in the application lifecycle to
468468
// timeline. The difference between this timestamp and the time we render
469469
// the very first frame gives us a good idea about Flutter's startup time.
470-
// Use a duration event so about:tracing will consider this event when
471-
// deciding the earliest event to use as time 0.
472-
if (settings_.engine_start_timestamp.count()) {
473-
Dart_TimelineEvent(
474-
"FlutterEngineMainEnter", // label
475-
settings_.engine_start_timestamp.count(), // timestamp0
476-
Dart_TimelineGetMicros(), // timestamp1_or_async_id
477-
Dart_Timeline_Event_Duration, // event type
478-
0, // argument_count
479-
nullptr, // argument_names
480-
nullptr // argument_values
481-
);
482-
}
470+
// Use an instant event because the call to Dart_TimelineGetMicros
471+
// may behave differently before and after the Dart VM is initialized.
472+
// As this call is immediately after initialization of the Dart VM,
473+
// we are interested in only one timestamp.
474+
int64_t micros = Dart_TimelineGetMicros();
475+
Dart_TimelineEvent("FlutterEngineMainEnter", // label
476+
micros, // timestamp0
477+
micros, // timestamp1_or_async_id
478+
Dart_Timeline_Event_Instant, // event type
479+
0, // argument_count
480+
nullptr, // argument_names
481+
nullptr // argument_values
482+
);
483483
}
484484

485485
Dart_SetFileModifiedCallback(&DartFileModifiedCallback);

shell/common/shell.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ void PerformInitializationTasks(Settings& settings) {
8484

8585
static std::once_flag gShellSettingsInitialization = {};
8686
std::call_once(gShellSettingsInitialization, [&settings] {
87-
if (settings.engine_start_timestamp.count() == 0) {
88-
settings.engine_start_timestamp =
89-
std::chrono::microseconds(Dart_TimelineGetMicros());
90-
}
91-
9287
tonic::SetLogHandler(
9388
[](const char* message) { FML_LOG(ERROR) << message; });
9489

shell/platform/android/flutter_main.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ void FlutterMain::Init(JNIEnv* env,
111111
settings.enable_timeline_event_handler = settings.trace_systrace;
112112
#endif // FLUTTER_RELEASE
113113

114-
int64_t init_time_micros = initTimeMillis * 1000;
115-
settings.engine_start_timestamp =
116-
std::chrono::microseconds(Dart_TimelineGetMicros() - init_time_micros);
117-
118114
// Restore the callback cache.
119115
// TODO(chinmaygarde): Route all cache file access through FML and remove this
120116
// setter.

0 commit comments

Comments
 (0)