[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay default font manager to run concurrently with isolate setup #29291

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test
  • Loading branch information
dnfield committed Oct 21, 2021
commit 05c18ca3847ed120dbb40659f39d2c3bee7c986f
8 changes: 4 additions & 4 deletions runtime/dart_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ std::weak_ptr<DartIsolate> DartIsolate::CreateRunningRootIsolate(
return {};
}

if (root_isolate_create_callback) {
root_isolate_create_callback();
}

if (settings.root_isolate_create_callback) {
// Isolate callbacks always occur in isolate scope and before user code has
// had a chance to run.
tonic::DartState::Scope scope(isolate.get());
settings.root_isolate_create_callback(*isolate.get());
}

if (root_isolate_create_callback) {
root_isolate_create_callback();
}

if (!isolate->RunFromLibrary(dart_entrypoint_library, //
dart_entrypoint, //
settings.dart_entrypoint_args //
Expand Down
2 changes: 1 addition & 1 deletion runtime/dart_isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class DartIsolate : public UIDartState {
/// isolate scope. This gives the
/// caller a chance to finish any
/// setup before running the Dart
/// program, and before any embedder
/// program, and after any embedder
/// callbacks in the settings object.
/// @param[in] isolate_create_callback The isolate create callback. This
/// will be called when the before the
Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class RuntimeController : public PlatformConfigurationClient {
/// root isolate has launched the Dart
/// program, but after it has been
/// created. This is called without
/// isolate scope, and before any root
/// isolate scope, and after any root
/// isolate callback in the settings.
/// @param[in] dart_entrypoint The dart entrypoint. If
/// `std::nullopt` or empty, `main` will
Expand Down
14 changes: 11 additions & 3 deletions shell/common/shell_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3068,8 +3068,7 @@ TEST_F(ShellTest, UserTagSetOnStartup) {
TEST_F(ShellTest, PrefetchDefaultFontManager) {
auto settings = CreateSettingsForFixture();
settings.prefetched_default_font_manager = true;

auto shell = CreateShell(std::move(settings));
std::unique_ptr<Shell> shell;

auto get_font_manager_count = [&] {
fml::AutoResetWaitableEvent latch;
Expand All @@ -3084,8 +3083,17 @@ TEST_F(ShellTest, PrefetchDefaultFontManager) {
latch.Wait();
return font_manager_count;
};
size_t initial_font_manager_count = 0;
settings.root_isolate_create_callback = [&](const auto& isolate) {
ASSERT_GT(initial_font_manager_count, 0ul);
// Should not have fetched the default font manager yet, since the root
// isolate was only just created.
ASSERT_EQ(get_font_manager_count(), initial_font_manager_count);
};

shell = CreateShell(std::move(settings));

size_t initial_font_manager_count = get_font_manager_count();
initial_font_manager_count = get_font_manager_count();

auto configuration = RunConfiguration::InferFromSettings(settings);
configuration.SetEntrypoint("emptyMain");
Expand Down