tryphotino / photino.NET

https://tryphotino.io
Apache License 2.0
885 stars 73 forks source link

Very poor performance on SBC's #163

Closed xcracing closed 8 months ago

xcracing commented 9 months ago

I'm running a simple web app on several SBC's - Raspberry Pi 3B, 4B -- Orange Pi 3B, 3 LTS, and even a Le Potato.

This app is creating a display board of changing data with some simple background fade transitions in CSS. There is no user interaction.

Issue is, it appears that webkit2gtk is not doing any hardware acceleration at all. CSS animations are horribly slow, etc. My CPUs are heating up, even with active cooling. I've benchmarked the same css/html on Chromium vs Webkit2Gtk via Photino and the difference is large, Chromium runs much better. I've even run the same code on Windows 10 IOT (on Raspberry Pi 3B) using UWP's web browser control based on Edge and it runs much better.

Is there something I'm missing - some verification I can do, or some settings I can adjust? I've tried on both Debian Bullseye and Bookworm "lite" non GUI versions running X server (not Wayland), with no difference. Running the latest version of WebGTK2

MikeYeager commented 9 months ago

@xcracing Webkit uses hardware acceleration by default according to their documentation. https://webkitgtk.org/reference/webkit2gtk/stable/property.Settings.hardware-acceleration-policy.html We don't explicitly change this setting, although you can override it on Linux OS's by setting startup flags. See https://github.com/tryphotino/photino.Native/issues/116 and https://lazka.github.io/pgi-docs/WebKit2-4.0/classes/Settings.html for details.

xcracing commented 9 months ago

Thanks for the response!

I'm not sure this is a resolvable problem on Photino's end unless there were a switch from Webkit2GTK to something that uses the Blink engine, like Chromium.

I did some testing using Epiphany browser which is based on Webkit2GTK - it performs exactly the same as my app using Photino. The problem is that Chromium outperforms Webkit2GTK by an order of magnitude as far as CSS rendering goes. For instance, in a CSS animation test I did, Chromium produced buttery smooth 30 FPS or better animations where Webkit2GTK did 3 to 4 FPS. WebGL on the other hand is a tie - both browsers performing equally on the WebGL aquarium test - so it seems that either Webkit2GTK is not hardware compositing or it's just really bad at it.

I was able to do a webkit://gpu with Epiphany (can that be done in Photino? If so, how?) and it seemed like all the hardware rendering was enabled, although it doesn't seem to have as comprehensive an output as Chrome://gpu - so it's hard to tell for sure.

Anyhow, unless there's an easy way to switch to Chromium instead of Webkit2GTK in Linux, I may have to scrap the app I've completed with Photino and try something else (maybe like controlling Chromium using Selenium as long as I can register events in the browser to talk back to C#). Thanks for the assistance - probably close this as a non Photino issue unless it results in being able to choose the browser engine on startup.

MikeYeager commented 8 months ago

@xcracing Sorry to hear this! Thank you for all of your work on this. Unfortunately, the Photno.Native code is the most difficult part of the project. It implements a native window with a native browser control 3 separate times (Windows, Linux, MacOS) using a common interface. This would require a 4th C++ implementation and we just don't have the bandwidth unless someone from the community steps up and volunteers to take it on. Even then it would increase the maintenance and testing a bit. We would like to make this option available to everyone, but it's a major undertaking. Perhaps Webkit2GTK will address this issue in the future and we'll all benefit from it.