@@ -23,51 +23,34 @@ namespace shell {
23
23
24
24
AndroidShellHolder::AndroidShellHolder (
25
25
blink::Settings settings,
26
- fml::jni::JavaObjectWeakGlobalRef java_object,
27
- bool is_background_view)
26
+ fml::jni::JavaObjectWeakGlobalRef java_object)
28
27
: settings_(std::move(settings)), java_object_(java_object) {
29
28
static size_t shell_count = 1 ;
30
29
auto thread_label = std::to_string (shell_count++);
31
30
32
31
FML_CHECK (pthread_key_create (&thread_destruct_key_, ThreadDestructCallback) ==
33
32
0 );
34
33
35
- if (is_background_view) {
36
- thread_host_ = {thread_label, ThreadHost::Type::UI};
37
- } else {
38
- thread_host_ = {thread_label, ThreadHost::Type::UI | ThreadHost::Type::GPU |
39
- ThreadHost::Type::IO};
40
- }
34
+ thread_host_ = {thread_label, ThreadHost::Type::UI | ThreadHost::Type::GPU |
35
+ ThreadHost::Type::IO};
41
36
42
37
// Detach from JNI when the UI and GPU threads exit.
43
38
auto jni_exit_task ([key = thread_destruct_key_]() {
44
39
FML_CHECK (pthread_setspecific (key, reinterpret_cast <void *>(1 )) == 0 );
45
40
});
46
41
thread_host_.ui_thread ->GetTaskRunner ()->PostTask (jni_exit_task);
47
- if (!is_background_view) {
48
- thread_host_.gpu_thread ->GetTaskRunner ()->PostTask (jni_exit_task);
49
- }
42
+ thread_host_.gpu_thread ->GetTaskRunner ()->PostTask (jni_exit_task);
50
43
51
44
fml::WeakPtr<PlatformViewAndroid> weak_platform_view;
52
45
Shell::CreateCallback<PlatformView> on_create_platform_view =
53
- [is_background_view, java_object, &weak_platform_view](Shell& shell) {
54
- std::unique_ptr<PlatformViewAndroid> platform_view_android;
55
- if (is_background_view) {
56
- platform_view_android = std::make_unique<PlatformViewAndroid>(
57
- shell, // delegate
58
- shell.GetTaskRunners (), // task runners
59
- java_object // java object handle for JNI interop
60
- );
61
-
62
- } else {
63
- platform_view_android = std::make_unique<PlatformViewAndroid>(
64
- shell, // delegate
65
- shell.GetTaskRunners (), // task runners
66
- java_object, // java object handle for JNI interop
67
- shell.GetSettings ()
68
- .enable_software_rendering // use software rendering
69
- );
70
- }
46
+ [java_object, &weak_platform_view](Shell& shell) {
47
+ auto platform_view_android = std::make_unique<PlatformViewAndroid>(
48
+ shell, // delegate
49
+ shell.GetTaskRunners (), // task runners
50
+ java_object, // java object handle for JNI interop
51
+ shell.GetSettings ()
52
+ .enable_software_rendering // use software rendering
53
+ );
71
54
weak_platform_view = platform_view_android->GetWeakPtr ();
72
55
return platform_view_android;
73
56
};
@@ -79,26 +62,13 @@ AndroidShellHolder::AndroidShellHolder(
79
62
// The current thread will be used as the platform thread. Ensure that the
80
63
// message loop is initialized.
81
64
fml::MessageLoop::EnsureInitializedForCurrentThread ();
82
- fml::RefPtr<fml::TaskRunner> gpu_runner;
83
- fml::RefPtr<fml::TaskRunner> ui_runner;
84
- fml::RefPtr<fml::TaskRunner> io_runner;
85
- fml::RefPtr<fml::TaskRunner> platform_runner =
86
- fml::MessageLoop::GetCurrent ().GetTaskRunner ();
87
- if (is_background_view) {
88
- auto single_task_runner = thread_host_.ui_thread ->GetTaskRunner ();
89
- gpu_runner = single_task_runner;
90
- ui_runner = single_task_runner;
91
- io_runner = single_task_runner;
92
- } else {
93
- gpu_runner = thread_host_.gpu_thread ->GetTaskRunner ();
94
- ui_runner = thread_host_.ui_thread ->GetTaskRunner ();
95
- io_runner = thread_host_.io_thread ->GetTaskRunner ();
96
- }
97
- blink::TaskRunners task_runners (thread_label, // label
98
- platform_runner, // platform
99
- gpu_runner, // gpu
100
- ui_runner, // ui
101
- io_runner // io
65
+
66
+ blink::TaskRunners task_runners (
67
+ thread_label, // label
68
+ fml::MessageLoop::GetCurrent ().GetTaskRunner (), // platform
69
+ thread_host_.gpu_thread ->GetTaskRunner (), // gpu
70
+ thread_host_.ui_thread ->GetTaskRunner (), // ui
71
+ thread_host_.io_thread ->GetTaskRunner () // io
102
72
);
103
73
104
74
shell_ =
@@ -161,12 +131,10 @@ void AndroidShellHolder::Launch(RunConfiguration config) {
161
131
fml::MakeCopyable ([engine = shell_->GetEngine (), //
162
132
config = std::move (config) //
163
133
]() mutable {
164
- FML_LOG (INFO) << " Attempting to launch engine configuration..." ;
165
- if (!engine || !engine->Run (std::move (config))) {
166
- FML_LOG (ERROR) << " Could not launch engine in configuration." ;
167
- } else {
168
- FML_LOG (INFO) << " Isolate for engine configuration successfully "
169
- " started and run." ;
134
+ if (engine) {
135
+ if (!engine->Run (std::move (config))) {
136
+ FML_LOG (ERROR) << " Could not launch engine in configuration." ;
137
+ }
170
138
}
171
139
}));
172
140
}
0 commit comments