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

Commit 5e54c70

Browse files
author
Emmanuel Garcia
authored
Reland: Enable hybrid composition by default on Android (#20722) (#20864)
This reverts commit 4de62c7.
1 parent 165abef commit 5e54c70

File tree

17 files changed

+36
-100
lines changed

17 files changed

+36
-100
lines changed

common/settings.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ 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-
235226
std::string ToString() const;
236227
};
237228

flow/surface.cc

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

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

flow/surface.h

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

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

36+
virtual bool ClearRenderContext();
37+
3638
private:
3739
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
3840
};

shell/common/rasterizer.cc

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

181+
if (surface_ != nullptr) {
182+
surface_->ClearRenderContext();
183+
}
184+
181185
// Merging the thread as we know the next `Draw` should be run on the platform
182186
// thread.
183187
if (surface_ != nullptr && surface_->GetExternalViewEmbedder() != nullptr) {

shell/common/switches.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@ 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-
235232
// Set Observatory Port
236233
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryPort))) {
237234
if (!GetSwitchValue(command_line, Switch::DeviceObservatoryPort,

shell/common/switches.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,7 @@ 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-
// 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.")
199+
208200
DEF_SWITCHES_END
209201

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

shell/gpu/gpu_surface_gl.cc

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

349+
// |Surface|
350+
bool GPUSurfaceGL::ClearRenderContext() {
351+
return delegate_->GLContextClearCurrent();
352+
}
353+
349354
} // namespace flutter

shell/gpu/gpu_surface_gl.h

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

51+
// |Surface|
52+
bool ClearRenderContext() override;
53+
5154
private:
5255
GPUSurfaceGLDelegate* delegate_;
5356
sk_sp<GrDirectContext> context_;

shell/platform/android/android_shell_holder.cc

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

31-
bool AndroidShellHolder::use_embedded_view;
32-
3331
AndroidShellHolder::AndroidShellHolder(
3432
flutter::Settings settings,
3533
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
@@ -102,47 +100,21 @@ AndroidShellHolder::AndroidShellHolder(
102100
ui_runner = thread_host_.ui_thread->GetTaskRunner();
103101
io_runner = thread_host_.io_thread->GetTaskRunner();
104102
}
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-
}
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+
);
146118

147119
platform_view_ = weak_platform_view;
148120
FML_DCHECK(platform_view_);

shell/platform/android/android_shell_holder.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ 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-
3224
AndroidShellHolder(flutter::Settings settings,
3325
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
3426
bool is_background_view);

shell/platform/android/android_surface_gl.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ intptr_t AndroidSurfaceGL::GLContextFBO(GLFrameInfo frame_info) const {
127127

128128
// |GPUSurfaceGLDelegate|
129129
ExternalViewEmbedder* AndroidSurfaceGL::GetExternalViewEmbedder() {
130-
if (!AndroidShellHolder::use_embedded_view) {
131-
return nullptr;
132-
}
133130
return external_view_embedder_.get();
134131
}
135132

shell/platform/android/android_surface_software.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ bool AndroidSurfaceSoftware::PresentBackingStore(
146146

147147
// |GPUSurfaceSoftwareDelegate|
148148
ExternalViewEmbedder* AndroidSurfaceSoftware::GetExternalViewEmbedder() {
149-
if (!AndroidShellHolder::use_embedded_view) {
150-
return nullptr;
151-
}
152149
return external_view_embedder_.get();
153150
}
154151

shell/platform/android/io/flutter/embedding/engine/loader/ApplicationInfoLoader.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ private static String getNetworkPolicy(ApplicationInfo appInfo, Context context)
7979
return output.toString();
8080
}
8181

82-
private static boolean getUseEmbeddedView(ApplicationInfo appInfo) {
83-
Bundle bundle = appInfo.metaData;
84-
return bundle != null && bundle.getBoolean("io.flutter.embedded_views_preview");
85-
}
86-
8782
private static void parseDomainConfig(
8883
XmlResourceParser xrp, JSONArray output, boolean inheritedCleartextPermitted)
8984
throws IOException, XmlPullParserException {
@@ -155,7 +150,6 @@ public static FlutterApplicationInfo load(@NonNull Context applicationContext) {
155150
getString(appInfo.metaData, PUBLIC_FLUTTER_ASSETS_DIR_KEY),
156151
getNetworkPolicy(appInfo, applicationContext),
157152
appInfo.nativeLibraryDir,
158-
clearTextPermitted,
159-
getUseEmbeddedView(appInfo));
153+
clearTextPermitted);
160154
}
161155
}

shell/platform/android/io/flutter/embedding/engine/loader/FlutterApplicationInfo.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ public final class FlutterApplicationInfo {
1818
final String domainNetworkPolicy;
1919
final String nativeLibraryDir;
2020
final boolean clearTextPermitted;
21-
// TODO(cyanlaz): Remove this when dynamic thread merging is done.
22-
// https://github.com/flutter/flutter/issues/59930
23-
final boolean useEmbeddedView;
2421

2522
public FlutterApplicationInfo(
2623
String aotSharedLibraryName,
@@ -29,8 +26,7 @@ public FlutterApplicationInfo(
2926
String flutterAssetsDir,
3027
String domainNetworkPolicy,
3128
String nativeLibraryDir,
32-
boolean clearTextPermitted,
33-
boolean useEmbeddedView) {
29+
boolean clearTextPermitted) {
3430
this.aotSharedLibraryName =
3531
aotSharedLibraryName == null ? DEFAULT_AOT_SHARED_LIBRARY_NAME : aotSharedLibraryName;
3632
this.vmSnapshotData = vmSnapshotData == null ? DEFAULT_VM_SNAPSHOT_DATA : vmSnapshotData;
@@ -41,6 +37,5 @@ public FlutterApplicationInfo(
4137
this.nativeLibraryDir = nativeLibraryDir;
4238
this.domainNetworkPolicy = domainNetworkPolicy == null ? "" : domainNetworkPolicy;
4339
this.clearTextPermitted = clearTextPermitted;
44-
this.useEmbeddedView = useEmbeddedView;
4540
}
4641
}

shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,6 @@ public void ensureInitializationComplete(
221221
if (flutterApplicationInfo.domainNetworkPolicy != null) {
222222
shellArgs.add("--domain-network-policy=" + flutterApplicationInfo.domainNetworkPolicy);
223223
}
224-
if (flutterApplicationInfo.useEmbeddedView) {
225-
shellArgs.add("--use-embedded-view");
226-
}
227224
if (settings.getLogTag() != null) {
228225
shellArgs.add("--log-tag=" + settings.getLogTag());
229226
}

shell/platform/android/test/io/flutter/embedding/engine/loader/ApplicationInfoLoaderTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public void itGeneratesCorrectApplicationInfoWithDefaultManifest() {
4747
assertEquals("", info.domainNetworkPolicy);
4848
assertNull(info.nativeLibraryDir);
4949
assertEquals(true, info.clearTextPermitted);
50-
assertEquals(false, info.useEmbeddedView);
5150
}
5251

5352
@Config(shadows = {ApplicationInfoLoaderTest.ShadowNetworkSecurityPolicy.class})
@@ -92,7 +91,6 @@ public void itGeneratesCorrectApplicationInfoWithCustomValues() throws Exception
9291
bundle.putString(ApplicationInfoLoader.PUBLIC_VM_SNAPSHOT_DATA_KEY, "testvmsnapshot");
9392
bundle.putString(ApplicationInfoLoader.PUBLIC_ISOLATE_SNAPSHOT_DATA_KEY, "testisolatesnapshot");
9493
bundle.putString(ApplicationInfoLoader.PUBLIC_FLUTTER_ASSETS_DIR_KEY, "testassets");
95-
bundle.putBoolean("io.flutter.embedded_views_preview", true);
9694
Context context = generateMockContext(bundle, null);
9795
FlutterApplicationInfo info = ApplicationInfoLoader.load(context);
9896
assertNotNull(info);
@@ -102,7 +100,6 @@ public void itGeneratesCorrectApplicationInfoWithCustomValues() throws Exception
102100
assertEquals("testassets", info.flutterAssetsDir);
103101
assertNull(info.nativeLibraryDir);
104102
assertEquals("", info.domainNetworkPolicy);
105-
assertEquals(true, info.useEmbeddedView);
106103
}
107104

108105
@Test

testing/scenario_app/android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
<category android:name="android.intent.category.LAUNCHER" />
3636
</intent-filter>
3737
</activity>
38-
<meta-data
39-
android:name="io.flutter.embedded_views_preview"
40-
android:value="true" />
4138
</application>
4239
<uses-permission android:name="android.permission.INTERNET" />
4340
</manifest>

0 commit comments

Comments
 (0)