Skip to content

Commit 4de62c7

Browse files
author
Emmanuel Garcia
authored
Revert "Enable hybrid composition by default on Android (flutter#20722)" (flutter#20745)
This reverts commit d16ba48.
1 parent 5dd3d44 commit 4de62c7

File tree

18 files changed

+101
-37
lines changed

18 files changed

+101
-37
lines changed

common/settings.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ struct Settings {
223223
/// to log a timeline event that tracks the latency of engine startup.
224224
std::chrono::microseconds engine_start_timestamp = {};
225225

226+
/// Whether the application claims that it uses the android embedded view for
227+
/// platform views.
228+
///
229+
/// A `true` value will result the raster task runner always run on the
230+
/// platform thread.
231+
// TODO(cyanlaz): Remove this when dynamic thread merging is done.
232+
// https://github.com/flutter/flutter/issues/59930
233+
bool use_embedded_view = false;
234+
226235
std::string ToString() const;
227236
};
228237

flow/surface.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,4 @@ std::unique_ptr<GLContextResult> Surface::MakeRenderContextCurrent() {
1818
return std::make_unique<GLContextDefaultResult>(true);
1919
}
2020

21-
bool Surface::ClearRenderContext() {
22-
return false;
23-
}
24-
2521
} // namespace flutter

flow/surface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class Surface {
3333

3434
virtual std::unique_ptr<GLContextResult> MakeRenderContextCurrent();
3535

36-
virtual bool ClearRenderContext();
37-
3836
private:
3937
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
4038
};

shell/common/rasterizer.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ void Rasterizer::Draw(fml::RefPtr<Pipeline<flutter::LayerTree>> pipeline) {
143143
consume_result = PipelineConsumeResult::MoreAvailable;
144144
}
145145

146-
if (surface_ != nullptr) {
147-
surface_->ClearRenderContext();
148-
}
149-
150146
// Merging the thread as we know the next `Draw` should be run on the platform
151147
// thread.
152148
if (surface_ != nullptr && surface_->GetExternalViewEmbedder() != nullptr) {

shell/common/switches.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
229229
: "127.0.0.1";
230230
}
231231

232+
settings.use_embedded_view =
233+
command_line.HasOption(FlagForSwitch(Switch::UseEmbeddedView));
234+
232235
// Set Observatory Port
233236
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryPort))) {
234237
if (!GetSwitchValue(command_line, Switch::DeviceObservatoryPort,

shell/common/switches.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,15 @@ DEF_SWITCH(
196196
"Uses separate threads for the platform, UI, GPU and IO task runners. "
197197
"By default, a single thread is used for all task runners. Only available "
198198
"in the flutter_tester.")
199-
199+
// TODO(cyanlaz): Remove this when dynamic thread merging is done.
200+
// https://github.com/flutter/flutter/issues/59930
201+
DEF_SWITCH(UseEmbeddedView,
202+
"use-embedded-view",
203+
"Whether an android application uses embedded views."
204+
"This is a temporary flag to make the raster task runner runs on "
205+
"the platform thread."
206+
"This flag should be removed once the dynamic thread merging is "
207+
"enabled on android.")
200208
DEF_SWITCHES_END
201209

202210
void PrintUsage(const std::string& executable_name);

shell/gpu/gpu_surface_gl.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,4 @@ std::unique_ptr<GLContextResult> GPUSurfaceGL::MakeRenderContextCurrent() {
341341
return delegate_->GLContextMakeCurrent();
342342
}
343343

344-
// |Surface|
345-
bool GPUSurfaceGL::ClearRenderContext() {
346-
return delegate_->GLContextClearCurrent();
347-
}
348-
349344
} // namespace flutter

shell/gpu/gpu_surface_gl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ class GPUSurfaceGL : public Surface {
4848
// |Surface|
4949
std::unique_ptr<GLContextResult> MakeRenderContextCurrent() override;
5050

51-
// |Surface|
52-
bool ClearRenderContext() override;
53-
5451
private:
5552
GPUSurfaceGLDelegate* delegate_;
5653
sk_sp<GrDirectContext> context_;

shell/platform/android/android_shell_holder.cc

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ static PlatformData GetDefaultPlatformData() {
2828
return platform_data;
2929
}
3030

31+
bool AndroidShellHolder::use_embedded_view;
32+
3133
AndroidShellHolder::AndroidShellHolder(
3234
flutter::Settings settings,
3335
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
@@ -100,21 +102,47 @@ AndroidShellHolder::AndroidShellHolder(
100102
ui_runner = thread_host_.ui_thread->GetTaskRunner();
101103
io_runner = thread_host_.io_thread->GetTaskRunner();
102104
}
103-
104-
flutter::TaskRunners task_runners(thread_label, // label
105-
platform_runner, // platform
106-
gpu_runner, // raster
107-
ui_runner, // ui
108-
io_runner // io
109-
);
110-
111-
shell_ =
112-
Shell::Create(task_runners, // task runners
113-
GetDefaultPlatformData(), // window data
114-
settings_, // settings
115-
on_create_platform_view, // platform view create callback
116-
on_create_rasterizer // rasterizer create callback
117-
);
105+
if (settings.use_embedded_view) {
106+
use_embedded_view = true;
107+
// Embedded views requires the gpu and the platform views to be the same.
108+
// The plan is to eventually dynamically merge the threads when there's a
109+
// platform view in the layer tree.
110+
// For now we use a fixed thread configuration with the same thread used as
111+
// the gpu and platform task runner.
112+
// TODO(amirh/chinmaygarde): remove this, and dynamically change the thread
113+
// configuration. https://github.com/flutter/flutter/issues/23975
114+
// https://github.com/flutter/flutter/issues/59930
115+
flutter::TaskRunners task_runners(thread_label, // label
116+
platform_runner, // platform
117+
platform_runner, // raster
118+
ui_runner, // ui
119+
io_runner // io
120+
);
121+
122+
shell_ =
123+
Shell::Create(task_runners, // task runners
124+
GetDefaultPlatformData(), // window data
125+
settings_, // settings
126+
on_create_platform_view, // platform view create callback
127+
on_create_rasterizer // rasterizer create callback
128+
);
129+
} else {
130+
use_embedded_view = false;
131+
flutter::TaskRunners task_runners(thread_label, // label
132+
platform_runner, // platform
133+
gpu_runner, // raster
134+
ui_runner, // ui
135+
io_runner // io
136+
);
137+
138+
shell_ =
139+
Shell::Create(task_runners, // task runners
140+
GetDefaultPlatformData(), // window data
141+
settings_, // settings
142+
on_create_platform_view, // platform view create callback
143+
on_create_rasterizer // rasterizer create callback
144+
);
145+
}
118146

119147
platform_view_ = weak_platform_view;
120148
FML_DCHECK(platform_view_);

shell/platform/android/android_shell_holder.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ namespace flutter {
2121

2222
class AndroidShellHolder {
2323
public:
24+
// Whether the application sets to use embedded_view view
25+
// `io.flutter.embedded_views_preview` flag. This can be static because it is
26+
// determined by the application and it is safe when there are multiple
27+
// `AndroidSurface`s.
28+
// TODO(cyanglaz): remove this when dynamic thread merging is enabled on
29+
// android. https://github.com/flutter/flutter/issues/59930
30+
static bool use_embedded_view;
31+
2432
AndroidShellHolder(flutter::Settings settings,
2533
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
2634
bool is_background_view);

0 commit comments

Comments
 (0)