问题描述
我正在使用 raspberry pi 4 上的 webkitgtk 构建自助服务终端应用程序.
此应用程序不会连接到 Internet,并且 UI 的所有 html、css、javascript 都位于本地文件系统中.
我正在使用 buildroot 来设置 Linux 系统,从 buildroot 中提供的 pi 4 defconfig 开始.
我已启用运行 webkitgtk 所需的所有软件包.
此外,Kiosk 应用程序已经在我的桌面上进行了测试,使用相同的软件堆栈并且可以正常工作
但是,当我尝试在 raspberry pi 上启动应用程序时,会弹出一个空白页面.我通过启用本地文件访问来处理与我的 WebKitWebView
关联的 WebKitWebSettings
对象.它仍然显示一个空白屏幕.
我的 pi4 应用程序包中还包含一个简单的 gtk3+ 应用程序.这成功启动!
我真的很感激一些关于为什么会发生这种情况的提示,因为我已经走到了死胡同
更新
我启用了 Webkitgtk 包附带的 MiniBrowser 应用程序.输入本地网址,页面未加载.它只在顶部给我一条消息已成功下载".它似乎将我的输入视为下载
更新 2
经过更多的实验,我终于能够让 webkitgtk 在 pi 4 上工作.问题似乎源于使用 webkit_web_view_load_uri()
api.
它似乎无法将我的 html 文档识别为网页.
我使用 webkit_web_view_load_html()
调用解决了这个问题.这包括一些技巧,首先将 html 文档的内容读入字符缓冲区,然后将其传递给 webkit_web_view_load_html()
.您还必须提供此函数调用的基本路径,以便能够解析 html 文档中的所有 url(脚本、css、图像等).
另一个我无法解决的问题是,SVG 图像没有加载到 webkitgtk 中.我使用过 jpg 格式并且它们有效.我怀疑这是由于构建 webkigtk 时的配置切换
如果无法访问您的环境和设置,我很难弄清楚可能会发生什么.我的直觉是页面显示为空白,因为可能缺少某些共享库.您可以通过以下方式检查:
$ ldd WebKitBuild/GTK/Release/bin/MiniBrowser
我正在使用 buildroot 来设置 Linux 系统,从 buildroot 中提供的 pi 4 defconfig 开始.
有一个用于为 RPi 构建 WPE 的 buildroot 存储库.WPE (WebPlatform for Embeded) 类似于 WebKitGTK,但不依赖于 GTK 工具包.另一个重要的区别是 WPE 在 Wayland 上本地运行.
如果您有兴趣在功能有限的设备上运行的浏览器中嵌入 Web 应用程序,WPE 是比 WebKitGTK 更好的选择.用于为 RPi 构建 WPE 的 buildroot 存储库在这里:
https://github.com/WebPlatformForEmbedded/buildroot
还有关于如何为 RPi3 构建 WPE 的这个非常有趣的分步指南:
https://samdecrock.medium.com/building-wpe-webkit-for-raspberry-pi-3-cdbd7b5cb362
我不确定 buildroot 配方是否适用于 RPi4.它似乎适用于所有以前的版本,因此如果您尝试在 RPi4 上构建 WPE,您可能会踏入新的领域.
如果您有可用的 RPi3,我会先尝试为 RPi3 构建 WPE,并确保它有效.然后尝试使用 RPi4.
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
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
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.
这篇关于WebkitGtk 应用程序未加载文件 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!