Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f6e260b

Browse files
Jonah Williamsharryterkelsen
authored andcommitted
[Impeller] Disable raster stats service protocol. (#47206)
As far as I can tell, this functionality has _always_ been falling back to software rendering with Skia when Impeller was enabled. This is at best extremely misleading. Since I started putting Impeller specific objects in the display list it introduced crashes, and must be disabled. Fixes flutter/flutter#136847
1 parent a39697e commit f6e260b

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

flow/layers/layer_tree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class LayerTree {
7070
/// When `Paint` is called, if leaf layer tracing is enabled, additional
7171
/// metadata around raterization of leaf layers is collected.
7272
///
73+
/// This is not supported in the Impeller backend.
74+
///
7375
/// See: `LayerSnapshotStore`
7476
void enable_leaf_layer_tracing(bool enable) {
7577
enable_leaf_layer_tracing_ = enable;

shell/common/shell.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,13 @@ bool Shell::OnServiceProtocolRenderFrameWithRasterStats(
19721972
rapidjson::Document* response) {
19731973
FML_DCHECK(task_runners_.GetRasterTaskRunner()->RunsTasksOnCurrentThread());
19741974

1975+
// Impeller does not support this protocol method.
1976+
if (io_manager_->GetImpellerContext()) {
1977+
const char* error = "Raster status not supported on Impeller backend.";
1978+
ServiceProtocolFailureError(response, error);
1979+
return false;
1980+
}
1981+
19751982
// TODO(dkwingsmt): This method only handles view #0, including the snapshot
19761983
// and the frame size. We need to adapt this method to multi-view.
19771984
// https://github.com/flutter/flutter/issues/131892

shell/common/shell_unittests.cc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,47 @@ TEST_F(ShellTest, OnServiceProtocolRenderFrameWithRasterStatsWorks) {
27092709
DestroyShell(std::move(shell));
27102710
}
27112711

2712+
#if defined(FML_OS_MACOSX)
2713+
TEST_F(ShellTest, OnServiceProtocolRenderFrameWithRasterStatsDisableImpeller) {
2714+
auto settings = CreateSettingsForFixture();
2715+
settings.enable_impeller = true;
2716+
std::unique_ptr<Shell> shell = CreateShell({
2717+
.settings = settings,
2718+
.platform_view_create_callback = ShellTestPlatformViewBuilder({
2719+
.rendering_backend =
2720+
ShellTestPlatformView::BackendType::kMetalBackend,
2721+
}),
2722+
});
2723+
2724+
// Create the surface needed by rasterizer
2725+
PlatformViewNotifyCreated(shell.get());
2726+
2727+
auto configuration = RunConfiguration::InferFromSettings(settings);
2728+
configuration.SetEntrypoint("scene_with_red_box");
2729+
2730+
RunEngine(shell.get(), std::move(configuration));
2731+
PumpOneFrame(shell.get());
2732+
2733+
ServiceProtocol::Handler::ServiceProtocolMap empty_params;
2734+
rapidjson::Document document;
2735+
OnServiceProtocol(
2736+
shell.get(), ServiceProtocolEnum::kRenderFrameWithRasterStats,
2737+
shell->GetTaskRunners().GetRasterTaskRunner(), empty_params, &document);
2738+
rapidjson::StringBuffer buffer;
2739+
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2740+
document.Accept(writer);
2741+
std::string actual_json = buffer.GetString();
2742+
std::string expected_json =
2743+
"{\"code\":-32000,\"message\":\"Raster status not supported on Impeller "
2744+
"backend.\"}";
2745+
2746+
ASSERT_EQ(actual_json, expected_json);
2747+
2748+
PlatformViewNotifyDestroyed(shell.get());
2749+
DestroyShell(std::move(shell));
2750+
}
2751+
#endif // FML_OS_MACOSX
2752+
27122753
// TODO(https://github.com/flutter/flutter/issues/100273): Disabled due to
27132754
// flakiness.
27142755
// TODO(https://github.com/flutter/flutter/issues/100299): Fix it when

0 commit comments

Comments
 (0)