Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

c - WebkitGtk application is not loading file URL

I am building a kiosk application using webkitgtk on the raspberry pi 4.

This application will not be connected to the internet and all the html,css, javascript for the UI are all located on the local filesystem.

I am using buildroot to setup the Linux system, starting with the pi 4 defconfig provided in buildroot.

I have enabled all the packages needed to get webkitgtk running.

Also, the kiosk application has been tested on my desktop, using the same software stack and it works

However, when i try to launch the application on the raspberry pi, a blank page pops up. I have played around with the WebKitWebSettings object associated with my WebKitWebView by enabling local file access. It still shows up a blank screen.

Also included in my pi4 application bundle is a simple gtk3+ application. This launches successfully!

I will really appreciate some pointers as to why this is happening as i have sort of reached a dead end

UPDATE

I enabled the MiniBrowser app that comes with the Webkitgtk package. Entering the local url, The page does not load. It only gives me a message at the top saying "Successfully downloaded". It seems to be treating my input as a download

UPDATE 2

After some more experimenting, i was finally able to get webkitgtk working on the pi 4. The problem seems to originate from using the webkit_web_view_load_uri() api.

It does not seem to recognize my html document as a web page.

I got around it using the webkit_web_view_load_html() call. This included some hacks by first reading in the contents of the html doc into a character buffer, and passing it to webkit_web_view_load_html(). You also have to provide a base path to this function call to be able to resolve all the urls (scripts, css, images etc) in your html document.

Another problem i haven't been able to work around is, SVG images are not loading in webkitgtk. I have used jpg formats and they work. I suspect this my be due to a configuration switch in building webkigtk


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's hard for me to figure out what might be happening without having access to your environment and settings. My gut feeling is that pages are showing blank because perhaps some shared libraries are missing. You can check that with:

$ ldd WebKitBuild/GTK/Release/bin/MiniBrowser

I am using buildroot to setup the Linux system, starting with the pi 4 defconfig provided in buildroot.

There's a buildroot repository for building WPE for RPi. WPE (WebPlatform for Embeded) is like WebKitGTK but doesn't depend on GTK toolkit. Another important difference is that WPE runs natively on Wayland.

If you're interested in having a webapp embedded in a browser running in a device with limited capabilities, WPE is a better choice than WebKitGTK. The buildroot repo for building WPE for RPi is here:

https://github.com/WebPlatformForEmbedded/buildroot

There's is also this very interesting step-by-step guide on how to build WPE for RPi3:

https://samdecrock.medium.com/building-wpe-webkit-for-raspberry-pi-3-cdbd7b5cb362

I'm not sure whether the buildroot recipe would work for RPi4. It seems to work for all previous versions, so you might be stepping in new land if you try to build WPE on RPi4.

If you have an RPi3 available I'd try to build WPE for RPi3 first, and make sure that works. Then try for RPi4.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...