Skip to content

Instantly share code, notes, and snippets.

@chinmaygarde
Created September 30, 2019 22:15
Show Gist options
  • Save chinmaygarde/530b27f954263ab9f91410de2888fcf2 to your computer and use it in GitHub Desktop.
Save chinmaygarde/530b27f954263ab9f91410de2888fcf2 to your computer and use it in GitHub Desktop.
Platform Task Runner Renders as Well
diff --git a/shell/platform/embedder/embedder_thread_host.cc b/shell/platform/embedder/embedder_thread_host.cc
index 5c2a1f3ae..e454bc76d 100644
--- a/shell/platform/embedder/embedder_thread_host.cc
+++ b/shell/platform/embedder/embedder_thread_host.cc
@@ -110,10 +110,10 @@ EmbedderThreadHost::CreateEmbedderManagedThreadHost(
flutter::TaskRunners task_runners(
kFlutterThreadName,
- platform_task_runner, // platform
- thread_host.gpu_thread->GetTaskRunner(), // gpu
- thread_host.ui_thread->GetTaskRunner(), // ui
- thread_host.io_thread->GetTaskRunner() // io
+ platform_task_runner, // platform
+ platform_task_runner, // gpu
+ thread_host.ui_thread->GetTaskRunner(), // ui
+ thread_host.io_thread->GetTaskRunner() // io
);
if (!task_runners.IsValid()) {
@@ -152,10 +152,10 @@ EmbedderThreadHost::CreateEngineManagedThreadHost() {
flutter::TaskRunners task_runners(
kFlutterThreadName,
- platform_task_runner, // platform
- thread_host.gpu_thread->GetTaskRunner(), // gpu
- thread_host.ui_thread->GetTaskRunner(), // ui
- thread_host.io_thread->GetTaskRunner() // io
+ platform_task_runner, // platform
+ platform_task_runner, // gpu
+ thread_host.ui_thread->GetTaskRunner(), // ui
+ thread_host.io_thread->GetTaskRunner() // io
);
if (!task_runners.IsValid()) {
@fourscience
Copy link

it would be nice to have the GPU thread as an exposed solution just like the platform thread, i had to patch this as well :D

@chinmaygarde
Copy link
Author

We are thinking about doing just that. Just trying to figure out how this would affect an existing embedder. I am curious about your use case though. Care to elaborate?

@fourscience
Copy link

Well the system itself uses QT wayland compositor (webos), and it's restricted yo use the main thread to call gl functions.
Atm, it's barebone wayland/egl runner with the modified engine, as far as i can tell this applies for some tizen devices as well.
I was looking into directfb to bypass the restrictions, but that's a different story.
For now our patch is more about extending the CustomTaskRunners and some nasty statements for the ThreadHost.
If you wan't i'll get the patch file and share, but it's not that well defined.
If you have a webos device nearby, you can push the executable with the default prisoner ssh user, and run it.
for webos3 https://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/arm-linux-gnueabi/
for webos4 https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/arm-linux-gnueabi/
Note that, this is just for evaluation, for a proper setup you would need to get the NDK from LG, but you can get along with this.
There is also a env variable "WEBOS_GL_DISABLE_THREADED_RENDERING" which could disable, did not went that route since the company decided to NOT use Flutter by default (the statement is that "it’s not realistic that we could spend enough effort on any given choice of framework / platform to make it useable on all our target platforms"), at least for iOS and Android and Web (i was doing the R&D), which is kind of sad, but for CTV/STB/Gaming Consoles the whole ecosystem could be a big game changes, since most of the apps are html/js based and a lot of the devices have different browser engines backing it up (example is a samsung 2016 device can have a different tizen, with a different webengine then a samsung 2017 device), so the biggest win here is a single reliable shell, netflix does use javascriptcore and their own stuff (gibbon) to do this, mostly with a React Native bridge. Same goes for https://developer.youi.tv/5.6.

Anyway, here is the bash that i use to run the app on the device itself,

#!/bin/sh

#. /etc/init.d/env.sh
# Setup the basic environment for wayland-server
XDG_RUNTIME_LOCATION="/var/run/xdg"
export XDG_RUNTIME_DIR=$XDG_RUNTIME_LOCATION
export VERBOSE=1
export WEBOS_GL_DISABLE_THREADED_RENDERING=0

export APP_PATH=$(cd ${0%/*}/.. && echo $PWD)
export NF_BIN_DIR="${APP_PATH}/bin"
export NF_LIB_DIR="${APP_PATH}/lib"
export DATA_PATH="${APP_PATH}/bin/flutter_assets"

export LD_LIBRARY_PATH=${NF_LIB_DIR}:/usr/lib:/mnt/lg/res/lglib:/mnt/lg/res/lglib/lib:/mnt/lg/res/lglib/openmax:/lib:${LD_LIBRARY_PATH}

exec ${NF_BIN_DIR}/app.bin ${DATA_PATH} --verbose-logging

Then probably you know the other stuff, if you want to give it a try.

Let me now if you need anything more about the use case :D or if you wan't me to get that patch we have laying around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment