Fix Webarchy WebKit renderer on the 2720 Flip
This commit is contained in:
1 parent
d4f0134e32
commit
77d95c715c
9 files changed
+259
-18
No files matched your search
@@ -1102,6 +1102,30 @@ for f in overlay/rootfs/etc/os-release overlay/rootfs/usr/lib/os-release
|
||||
fi
|
||||
done
|
||||
|
||||
echo "[check] Webarchy WebKit renderer profile..."
|
||||
WEBARCHY_SRC="$BASE_DIR/src/dwm-plugins/webarchy_plugin.cpp"
|
||||
WEBARCHY_SO="$BASE_DIR/prebuilt/sxmo-x11/usr/lib/dwm/plugins/webarchy.so"
|
||||
for token in 'webarchySoftwareRendererPreferred' 'configureWebkitRenderer' \
|
||||
'WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER' 'nokia,beatles'; do
|
||||
if ! grep -qF "$token" "$WEBARCHY_SRC"; then
|
||||
fail "webarchy_plugin.cpp is missing the $token renderer fallback"
|
||||
fi
|
||||
done
|
||||
if grep -qF 'WEBKIT_DISABLE_DMABUF_RENDERER", "0"' "$WEBARCHY_SRC" || \
|
||||
grep -qF 'WEBKIT_DISABLE_COMPOSITING_MODE", "0"' "$WEBARCHY_SRC"; then
|
||||
fail "WebKit presence flags must never be defined as 0"
|
||||
fi
|
||||
if ! strings "$WEBARCHY_SO" 2>/dev/null | grep -qF 'nokia,beatles'; then
|
||||
fail "shipped webarchy.so is stale: rebuild with scripts/build-sxmo-x11.sh"
|
||||
fi
|
||||
if [ ! -x "$BASE_DIR/scripts/test-webarchy-renderer.py" ]; then
|
||||
fail "missing host unit test scripts/test-webarchy-renderer.py"
|
||||
fi
|
||||
if command -v g++ >/dev/null 2>&1 && \
|
||||
! "$BASE_DIR/scripts/test-webarchy-renderer.py" >/dev/null 2>&1; then
|
||||
fail "host webarchy renderer profile test failed"
|
||||
fi
|
||||
|
||||
if [ "$FAILURES" -ne 0 ]; then
|
||||
echo "[check] $FAILURES check(s) failed."
|
||||
exit 1
|
||||
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Host unit test for Webarchy's WebKit renderer profile selection.
|
||||
|
||||
The plugin is cross-compiled for armv7 inside Docker. This test extracts the
|
||||
three renderer-profile functions from webarchy_plugin.cpp and compiles them on
|
||||
the host with stubbed device-tree and home paths, so the device matrix and the
|
||||
WebKit presence-flag handling can be verified without a phone.
|
||||
"""
|
||||
import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
BASE = pathlib.Path(__file__).resolve().parent.parent
|
||||
SOURCE = BASE / "src/dwm-plugins/webarchy_plugin.cpp"
|
||||
FUNCTIONS = (
|
||||
"std::string deviceTreeCompatibles",
|
||||
"bool webarchySoftwareRendererPreferred",
|
||||
"void configureWebkitRenderer",
|
||||
)
|
||||
|
||||
|
||||
def extract(name, text):
|
||||
start = text.find("\n" + name + "(")
|
||||
if start < 0:
|
||||
raise SystemExit("missing function %s in webarchy_plugin.cpp" % name)
|
||||
start += 1
|
||||
depth = 0
|
||||
opened = False
|
||||
for pos in range(start, len(text)):
|
||||
if text[pos] == "{":
|
||||
depth += 1
|
||||
opened = True
|
||||
elif text[pos] == "}":
|
||||
depth -= 1
|
||||
if opened and depth == 0:
|
||||
return text[start:pos + 1] + "\n"
|
||||
raise SystemExit("unterminated function %s" % name)
|
||||
|
||||
|
||||
HARNESS_HEAD = r'''
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
static const char* g_compat_path = nullptr;
|
||||
static const char* g_home = nullptr;
|
||||
|
||||
std::string getHomeDirPath() { return std::string(g_home); }
|
||||
|
||||
SOFTWARE_FLAG
|
||||
|
||||
#define CHECK(cond) do { \
|
||||
if (!(cond)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); return 1; } \
|
||||
} while (0)
|
||||
|
||||
'''
|
||||
|
||||
HARNESS_MAIN = r'''
|
||||
int main(int argc, char** argv) {
|
||||
CHECK(argc == 4);
|
||||
g_compat_path = argv[1];
|
||||
g_home = argv[2];
|
||||
const int expect_software = (argv[3][0] == '1');
|
||||
std::string flag = std::string(g_home) + kSoftwareRendererFlag;
|
||||
|
||||
CHECK(webarchySoftwareRendererPreferred() == (expect_software != 0));
|
||||
::unlink(flag.c_str());
|
||||
::setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "0", 1);
|
||||
::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "0", 1);
|
||||
::setenv("JSC_useJIT", "0", 1);
|
||||
configureWebkitRenderer(false);
|
||||
CHECK(::getenv("WEBKIT_DISABLE_DMABUF_RENDERER") == nullptr);
|
||||
CHECK(::getenv("WEBKIT_DISABLE_COMPOSITING_MODE") == nullptr);
|
||||
CHECK(std::string(::getenv("JSC_useJIT")) == "0");
|
||||
|
||||
FILE* f = std::fopen(flag.c_str(), "wb");
|
||||
CHECK(f != nullptr);
|
||||
std::fclose(f);
|
||||
CHECK(webarchySoftwareRendererPreferred());
|
||||
configureWebkitRenderer(true);
|
||||
CHECK(std::string(::getenv("WEBKIT_DISABLE_DMABUF_RENDERER")) == "1");
|
||||
CHECK(std::string(::getenv("WEBKIT_SKIA_ENABLE_CPU_RENDERING")) == "1");
|
||||
CHECK(std::string(::getenv("WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS")) == "1");
|
||||
CHECK(std::string(::getenv("GDK_BACKEND")) == "x11");
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
def main():
|
||||
text = SOURCE.read_text(encoding="utf-8")
|
||||
flag_decl = re.search(
|
||||
r'constexpr const char\* kSoftwareRendererFlag =\s*"([^"]+)";', text)
|
||||
if not flag_decl:
|
||||
raise SystemExit("missing kSoftwareRendererFlag in webarchy_plugin.cpp")
|
||||
funcs = "\n".join(extract(name, text) for name in FUNCTIONS)
|
||||
funcs = funcs.replace('"/proc/device-tree/compatible"', 'g_compat_path')
|
||||
if '"/proc/device-tree/compatible"' in funcs:
|
||||
raise SystemExit("could not redirect the device-tree path")
|
||||
harness = HARNESS_HEAD.replace(
|
||||
"SOFTWARE_FLAG",
|
||||
'constexpr const char* kSoftwareRendererFlag = "%s";' % flag_decl.group(1))
|
||||
harness += funcs + HARNESS_MAIN
|
||||
with tempfile.TemporaryDirectory(prefix="bananarchy-webarchy-") as tmp:
|
||||
root = pathlib.Path(tmp)
|
||||
src = root / "renderer_test.cpp"
|
||||
exe = root / "renderer_test"
|
||||
compat = root / "compatible"
|
||||
home = root / "home"
|
||||
(home / ".config/sxmo").mkdir(parents=True)
|
||||
flag = home / flag_decl.group(1).lstrip("/")
|
||||
src.write_text(harness, encoding="utf-8")
|
||||
build = subprocess.run(
|
||||
["g++", "-std=c++20", "-Wall", "-Wextra", "-Werror", str(src), "-o", str(exe)],
|
||||
capture_output=True, text=True)
|
||||
if build.returncode:
|
||||
sys.stderr.write(build.stderr)
|
||||
return 1
|
||||
cases = (
|
||||
("argon", b"nokia,argon\0qcom,msm8905\0", "0", False),
|
||||
("beatles", b"nokia,beatles\0nokia,argon\0qcom,msm8905\0", "1", False),
|
||||
("argon + override", b"nokia,argon\0qcom,msm8905\0", "1", True),
|
||||
)
|
||||
for label, data, expected, override in cases:
|
||||
compat.write_bytes(data)
|
||||
if override:
|
||||
flag.write_bytes(b"1\n")
|
||||
elif flag.exists():
|
||||
flag.unlink()
|
||||
probe = subprocess.run([str(exe), str(compat), str(home), expected],
|
||||
capture_output=True, text=True)
|
||||
if probe.returncode:
|
||||
sys.stderr.write("%s: %s" % (label, probe.stderr))
|
||||
return 1
|
||||
print("[ok] renderer profile: %s" % label)
|
||||
print("webarchy renderer profile: all checks passed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user