Has anyone found a good solution for WebView on Co...
# compose-desktop
m
Has anyone found a good solution for WebView on Compose/Desktop? Compose WebView multiplatform right now uses KCEF (which bundles an entire copy of Chromium). Even that doesn't initialize on ubuntu for me (same issue as noted on WebViewKO below) WebViewKO - doesn't seem to want to cooperate on Ubuntu: https://github.com/Winterreisender/webviewko/issues/17 WebViewJava - I can get it to run, but demo of connecting with AWT/Swing crashes. Doesn't seem to be currently maintained. My current workaround: running web content in an internal web server, and running chrome with the --app command (removes the address bar etc). This seems like a major gap in the Compose/Desktop platform: most real world apps use webviews somewhere (authentication, external content presentation, etc)
If someone just needs to display css/html that they control, then https://github.com/radkovo/CSSBox/ can work (but if the css/html is external, or Javascript is involved, then it might not display as desired).
b
For authentication you can also use custom protocol handlers.
m
I don't have a problem serving content... I have an embedded http server... Problem has been getting a webview that will actually display something
e.g. the login form itself if doing authentication
h
I haven't tried it myself, but I know that JetbrainsRuntime (JBR) now includes JCEF. There must be a way to create a webview in Jetpack Compose.
m
You'd think so... but I have been through many paths (as per the github issues posted) - and there doesn't seem to be a reliable / well supported way to do it
Also - I think requiring the use of an Embedded Chromium (100MB+, after download, uses 400MB+) to display basic HTML/CSS/JS is far from ideal
h
Perhaps you could tell us more about the application you're developing. Why is HTML absolutely necessary to render content generated by the application itself?
m
I'm developing an open source learning management system that is optimized for offline and limited connectivity environments. I need to render EPubs (ebooks - which are essentially zipped HTML with some manifests)
An epub Manifest has a spine - which is essentially a sequence of HTML files that are contained in the zip.
e.g. the ideal way to handle it would be to use a LazyColumn where each item is a WebView that loads the given document
h
I see, it's not a simple problem, I don't think you'll be able to fully support the Epub 3 format without embedding a full browser. Have you considered the PDF format?
m
I already implemented PDF support (using PDFBox to render)
A lot of content comes in EPUB... and epub is much better for reading on screen as it is responsive to screen size
WebviewKO was an attempt at using webview.dev exactly for this problem - uses libraries already found on the native system
h
Looking at the error message, Gtk-Message: 204958.186: Failed to load module "canberra-gtk-module". I have the impression that this is something that could be solved by telling the application where to look for libraries, I had to configure LD_LIBRARY_PATH in one of my projects so that my JNI module could find another library on certain systems.
m
This "Gtk-Message: 174749.115: Failed to load module "canberra-gtk-module"" message comes every time I run my desktop app (and with some other apps on my system), doesn't seem to be a problem
I think this "(java:122608): GLib-GObject-CRITICAL **: 204958.233: cannot register existing type 'GdkDisplayManager'" is the problem
237 Views