diff --git a/fml/platform/fuchsia/message_loop_fuchsia.cc b/fml/platform/fuchsia/message_loop_fuchsia.cc index 4e44c913cac46..9a3c1c0ef8d32 100644 --- a/fml/platform/fuchsia/message_loop_fuchsia.cc +++ b/fml/platform/fuchsia/message_loop_fuchsia.cc @@ -6,14 +6,23 @@ #include #include +#include #include namespace fml { MessageLoopFuchsia::MessageLoopFuchsia() - : loop_(&kAsyncLoopConfigAttachToCurrentThread) {} + : loop_(&kAsyncLoopConfigNoAttachToCurrentThread) { + async_set_default_dispatcher(loop_.dispatcher()); +} -MessageLoopFuchsia::~MessageLoopFuchsia() = default; +MessageLoopFuchsia::~MessageLoopFuchsia() { + // It is only safe to unset the current thread's default dispatcher if it is + // already pointing to this loop. + if (async_get_default_dispatcher() == loop_.dispatcher()) { + async_set_default_dispatcher(nullptr); + } +} void MessageLoopFuchsia::Run() { loop_.Run(); diff --git a/shell/common/animator_unittests.cc b/shell/common/animator_unittests.cc index bf2ac9f5a9cf1..34acb1d45ddb3 100644 --- a/shell/common/animator_unittests.cc +++ b/shell/common/animator_unittests.cc @@ -46,9 +46,9 @@ TEST_F(ShellTest, VSyncTargetTime) { }; // create a shell with a constant firing vsync waiter. - fml::AutoResetWaitableEvent shell_creation; - auto platform_task = std::async(std::launch::async, [&]() { + fml::MessageLoop::EnsureInitializedForCurrentThread(); + shell = Shell::Create( task_runners, settings, [vsync_clock, &create_vsync_waiter](Shell& shell) { @@ -67,10 +67,8 @@ TEST_F(ShellTest, VSyncTargetTime) { configuration.SetEntrypoint("onBeginFrameMain"); RunEngine(shell.get(), std::move(configuration)); - shell_creation.Signal(); }); - - shell_creation.Wait(); + platform_task.wait(); // schedule a frame to trigger window.onBeginFrame fml::TaskRunner::RunNowOrPostTask(shell->GetTaskRunners().GetUITaskRunner(), diff --git a/testing/fuchsia/meta/fuchsia_test.cmx b/testing/fuchsia/meta/fuchsia_test.cmx index 2d9addc8fc89a..02ac9472b0930 100644 --- a/testing/fuchsia/meta/fuchsia_test.cmx +++ b/testing/fuchsia/meta/fuchsia_test.cmx @@ -13,6 +13,7 @@ "fuchsia.process.Launcher", "fuchsia.deprecatedtimezone.Timezone", "fuchsia.netstack.Netstack", + "fuchsia.sysmem.Allocator", "fuchsia.vulkan.loader.Loader", "fuchsia.logger.LogSink", "fuchsia.tracing.provider.Registry" diff --git a/testing/fuchsia/run_tests.sh b/testing/fuchsia/run_tests.sh index 05ffac4bd21ff..2c39beb0565bd 100755 --- a/testing/fuchsia/run_tests.sh +++ b/testing/fuchsia/run_tests.sh @@ -76,7 +76,6 @@ echo "$(date) END:EXTRACT_PACKAGES -----------------------------------" # TODO(gw280): Enable tests using JIT runner - echo "$(date) START:flutter_runner_tests ----------------------------" ./fuchsia_ctl -d $device_name test \ -f flutter_aot_runner-0.far \ @@ -93,14 +92,15 @@ echo "$(date) START:flutter_runner_tests ----------------------------" --identity-file $pkey \ --timeout-seconds $test_timeout_seconds \ --packages-directory packages +echo "$(date) DONE:flutter_runner_tests ----------------------------" -# TODO(https://github.com/flutter/flutter/issues/50032) Enable after the -# Fuchsia message loop migration is complete. +# TODO(https://github.com/flutter/flutter/issues/??): Re-enable +# FileTest's once they pass on Fuchsia. echo "$(date) START:fml_tests ---------------------------------------" ./fuchsia_ctl -d $device_name test \ -f fml_tests-0.far \ -t fml_tests \ - -a "--gtest_filter=-MessageLoop*:Message*:FileTest*" \ + -a "--gtest_filter=-FileTest*" \ --identity-file $pkey \ --timeout-seconds $test_timeout_seconds \ --packages-directory packages @@ -117,26 +117,24 @@ echo "$(date) START:flow_tests --------------------------------------" echo "$(date) DONE:flow_tests ---------------------------------------" -# TODO(kaushikiska): Runtime and shell tests are failing with -# async_dispatcher failures. Re-enable them once this gets fixed. - -# echo "$(date) START:runtime_tests -----------------------------------" -# ./fuchsia_ctl -d $device_name test \ -# -f runtime_tests-0.far \ -# -t runtime_tests \ -# --identity-file $pkey \ -# --timeout-seconds $test_timeout_seconds \ -# --packages-directory packages - +echo "$(date) START:runtime_tests -----------------------------------" +./fuchsia_ctl -d $device_name test \ + -f runtime_tests-0.far \ + -t runtime_tests \ + --identity-file $pkey \ + --timeout-seconds $test_timeout_seconds \ + --packages-directory packages +echo "$(date) DONE:runtime_tests -----------------------------------" # TODO(https://github.com/flutter/flutter/issues/53399): Re-enable # OnServiceProtocolGetSkSLsWorks, CanLoadSkSLsFromAsset, and # CanRemoveOldPersistentCache once they pass on Fuchsia. -# echo "$(date) START:shell_tests -------------------------------------" -# ./fuchsia_ctl -d $device_name test \ -# -f shell_tests-0.far \ -# -t shell_tests \ -# -a "--gtest_filter=-ShellTest.CacheSkSLWorks:ShellTest.SetResourceCacheSize*:ShellTest.OnServiceProtocolGetSkSLsWorks:ShellTest.CanLoadSkSLsFromAsset:ShellTest.CanRemoveOldPersistentCache" \ -# --identity-file $pkey \ -# --timeout-seconds $test_timeout_seconds \ -# --packages-directory packages +echo "$(date) START:shell_tests -------------------------------------" +./fuchsia_ctl -d $device_name test \ + -f shell_tests-0.far \ + -t shell_tests \ + -a "--gtest_filter=-ShellTest.CacheSkSLWorks:ShellTest.SetResourceCacheSize*:ShellTest.OnServiceProtocolGetSkSLsWorks:ShellTest.CanLoadSkSLsFromAsset:ShellTest.CanRemoveOldPersistentCache" \ + --identity-file $pkey \ + --timeout-seconds $test_timeout_seconds \ + --packages-directory packages +echo "$(date) DONE:shell_tests -----------------------------------"