Skip to content

Commit b433957

Browse files
author
Jonah Williams
committed
[Impeller] Disable raster stats service protocol. (flutter#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 abdaabc commit b433957

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
@@ -1968,6 +1968,13 @@ bool Shell::OnServiceProtocolRenderFrameWithRasterStats(
19681968
rapidjson::Document* response) {
19691969
FML_DCHECK(task_runners_.GetRasterTaskRunner()->RunsTasksOnCurrentThread());
19701970

1971+
// Impeller does not support this protocol method.
1972+
if (io_manager_->GetImpellerContext()) {
1973+
const char* error = "Raster status not supported on Impeller backend.";
1974+
ServiceProtocolFailureError(response, error);
1975+
return false;
1976+
}
1977+
19711978
// TODO(dkwingsmt): This method only handles view #0, including the snapshot
19721979
// and the frame size. We need to adapt this method to multi-view.
19731980
// 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
@@ -2713,6 +2713,47 @@ TEST_F(ShellTest, OnServiceProtocolRenderFrameWithRasterStatsWorks) {
27132713
DestroyShell(std::move(shell));
27142714
}
27152715

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

0 commit comments

Comments
 (0)