Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 7 additions & 5 deletions shell/platform/fuchsia/flutter/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ Engine::Engine(Delegate& delegate,
});
};

// Launch the engine in the appropriate configuration.
// Note: this initializes the Asset Manager on the global PersistantCache
// so it must be called before WarmupSkps() is called below.
auto run_configuration = flutter::RunConfiguration::InferFromSettings(
settings, task_runners.GetIOTaskRunner());

// Setup the callback that will instantiate the platform view.
flutter::Shell::CreateCallback<flutter::PlatformView>
on_create_platform_view = fml::MakeCopyable(
Expand Down Expand Up @@ -375,10 +381,6 @@ Engine::Engine(Delegate& delegate,
};
}

// Launch the engine in the appropriate configuration.
auto run_configuration = flutter::RunConfiguration::InferFromSettings(
shell_->GetSettings(), shell_->GetTaskRunners().GetIOTaskRunner());

auto on_run_failure = [weak = weak_factory_.GetWeakPtr()]() {
// The engine could have been killed by the caller right after the
// constructor was called but before it could run on the UI thread.
Expand Down Expand Up @@ -647,7 +649,7 @@ void Engine::WarmupSkps(fml::BasicTaskRunner* concurrent_task_runner,

// tell concurrent task runner to deserialize all skps available from
// the asset manager
concurrent_task_runner->PostTask([&raster_task_runner, skp_warmup_surface,
concurrent_task_runner->PostTask([raster_task_runner, skp_warmup_surface,
&surface_producer]() {
TRACE_DURATION("flutter", "DeserializeSkps");
std::vector<std::unique_ptr<fml::Mapping>> skp_mappings =
Expand Down
19 changes: 15 additions & 4 deletions shell/platform/fuchsia/flutter/tests/engine_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ class MockTaskRunner : public fml::BasicTaskRunner {
virtual ~MockTaskRunner() {}

void PostTask(const fml::closure& task) override {
task_count_++;
task();
outstanding_tasks_.push(task);
}

int GetTaskCount() { return task_count_; }

void Run() {
while (!outstanding_tasks_.empty()) {
outstanding_tasks_.front()();
outstanding_tasks_.pop();
task_count_++;
}
}

private:
int task_count_ = 0;
std::queue<const fml::closure> outstanding_tasks_;
};

class EngineTest : public ::testing::Test {
Expand All @@ -53,15 +61,16 @@ class EngineTest : public ::testing::Test {

fuchsia::ui::scenic::SessionPtr session_ptr;
scenic::Session session(std::move(session_ptr));
VulkanSurfaceProducer surface_producer(&session);
surface_producer_ = std::make_unique<VulkanSurfaceProducer>(&session);

Engine::WarmupSkps(&concurrent_task_runner_, &raster_task_runner_,
surface_producer);
*surface_producer_);
}

protected:
MockTaskRunner concurrent_task_runner_;
MockTaskRunner raster_task_runner_;
std::unique_ptr<VulkanSurfaceProducer> surface_producer_;
};

TEST_F(EngineTest, SkpWarmup) {
Expand Down Expand Up @@ -100,6 +109,8 @@ TEST_F(EngineTest, SkpWarmup) {
PersistentCache::GetCacheForProcess()->SetAssetManager(asset_manager);

WarmupSkps();
concurrent_task_runner_.Run();
raster_task_runner_.Run();

EXPECT_EQ(concurrent_task_runner_.GetTaskCount(), 1);
EXPECT_EQ(raster_task_runner_.GetTaskCount(), 1);
Expand Down