Almamu / linux-wallpaperengine

Wallpaper Engine backgrounds for Linux!
GNU General Public License v3.0
1.59k stars 61 forks source link

Add support for web backgrounds #153

Open Almamu opened 1 year ago

Almamu commented 1 year ago

Off the top of my head, functionality that we should need to support for web backgrounds:

Pasalc commented 9 months ago

I will try to implement it with "offscreen render".

I'm aware of 3 different tools that can render html/javascript:

Gecko/Spidermonkey

Gecko is browser engine by Mozilla. It can render html. SpiderMonkey is Mozilla’s JavaScript and WebAssembly Engine. If I get it right, embedding with Gecko/Spidermonkey is now deprecated. But there is successor, known as Servo.

Servo

Servo is a web rendering engine written in Rust, with WebGL and WebGPU support, and adaptable to desktop, mobile, and embedded applications.

Servo was dead for past 2 years, but now it's back to life and under stewardship of Linux Foundation Europe. It's not ready to use for now(at least I haven't found any instructions for embedding in C++ code), but there is already issue in progress with implementation of offscreen rendering, so my guess is that in next 2-3 months it would be possible to use here.

libcef

The Chromium Embedded Framework (CEF) is a simple framework for embedding Chromium-based browsers in other applications.

I already managed to embed simple wallpaper(3026516467) with it. But it will require more work to actually make it usable. For now I will focus on libcef, though in future servo might be a better choice.

Almamu commented 8 months ago

@Pasalc to be honest any progress at all on this is welcomed. Ideally we'd use libcef mainly because I think that's what wallpaper engine is currently using in their versions (well, wp and almost everyone else), so to get the best compatibility we should aim to at least support that one. One thing that'd be interesting is to have the option to support other browser engines in the future, so people that dislike chromium can at least get something out of this, but for now having anything working at all would be a big step forward.

Pasalc commented 8 months ago

Made pull request with some basic support for web wallpapers. Despite the fact that it's working, I'm not sure that it's ready for merge, cause it may break something for other people. Plus CEF required a lot of changes to cmake for it to compile, including some compilation flags, so now there are really a lot of warning popping out at compilation.

I would probably write code review of it tomorrow.

Some notes:

  1. Web wallpapers with dependencies are not supported for now(and there are a lot of web wallpapers with dependencies)
  2. CEF limits FPS for web wallpapers to 60.
  3. CEF doesn't provide a way to render frame on demand, so actual amount of FPS is smaller than chosen by user.

2 and 3 probably could be solved, but I'm not sure if it's really that important.

Pasalc commented 8 months ago

@Almamu I didn't find how to squash all commits in one with pull request, so if it's not possible on your side either I'll just make new branch with commits squashed for pull request.

Almamu commented 7 months ago

@Pasalc Sorry for the late reply, life is a bit busy lately. Squashing should be possible on the PR, no worries there ;). I'll download the PR and play with it a little bit and see how things go but the changes look good imo!

Zerwin commented 3 months ago

Not sure how relevant, but CEF still has some problems with wayland, see https://bitbucket.org/chromiumembedded/cef/pull-requests/288

CEF on Wayland is already there. It’s just it doesn’t support proper embedding (aka client is creating a wl_surface and embeds that into Chromium). If I’m not mistaken, it’s the views usage that works.

Might just be good to keep in mind

Almamu commented 3 months ago

Not sure how relevant, but CEF still has some problems with wayland, see https://bitbucket.org/chromiumembedded/cef/pull-requests/288

CEF on Wayland is already there. It’s just it doesn’t support proper embedding (aka client is creating a wl_surface and embeds that into Chromium). If I’m not mistaken, it’s the views usage that works.

Might just be good to keep in mind

@Pasalc already did the implementation and the PR got merged into main some days ago after some testing by myself on X11 and Wayland. I did make slight changes to it so multiple screens work just fine. It seemed to work just fine on both X11 and Wayland using Offscreen rendering based off my testing, but please feel free to open an issue if web background support doesn't work like it's supposed to. Take in mind that backgrounds with dependencies do not work yet, I plan to look into this soon-ish.