Add support for WebView
Added support for webview and changed qArgc in launch.cpp from 0 to 1 since webview expects QCoreApplication to atleast have the program name as argument, otherwise aborts leading to a crash in quickshell.
Changing qArgC is fine but I do not want to force a dependency on qtwebview or qtwebengine. Can we avoid calling initialize?
According to the docs: (https://doc.qt.io/qt-6/qml-qtwebview-webview.html#details)
To make the Qt WebView module function correctly across all platforms, it is necessary to call QtWebView::initialize() right after creating the QGuiApplicationinstance.
In https://doc.qt.io/qt-6/qtwebview.html they clarify that: This function initializes resources or sets options that are required by the different back-ends.
I tested it both with initialize() and without on my laptop and PC, and observed no visible issues. So it might work. However, there are no guarantees, and using it could lead to hard-to-debug undefined behavior when others start using or distributing configurations with WebView enabled. Since quickshell targets Linux only, I might review the QtWebView source for initialize() and try to implement it directly in qs, assuming the implementation is not too complex. This would avoid the dependency, though we would need to manually keep the code in sync with upstream.
if the initialization logic is complex, an acceptable solution would be to have a skeleton header with just that static function, and load the module dynamically if a pragma is set.
Alright. I removed the cmake options and added the pragma. When set to true it now calls the init function in webengine/webengine.hpp which attempts to load the appropriate library and symbol to call QtWebEngineQuick::initialize. Since webengine.hpp is only included by launch.cpp I figured offloading the function to a .cpp was not necessary.
Looks acceptable, though loading a symbol with a mangled name seems a little iffy https://doc.qt.io/qt-6/qlibrary.html#resolve. Can you add a manual test so we can make sure it still works in the future?
I agree, but that was the best solution I managed to come up with, and unless they modify the symbol somehow, it should work just fine. Also added a regular test for the init function, unless you meant some other form of test with "manual test"
Any update on this one? Thanks!
Alright so I forgot about this last time because setting up the env to get it loading was annoying, but did that now. Anyway I haven't been able to get it to not immediately crash. If it is actually working for people we can merge this anyway though.
build/src/quickshell -p ../test/webengine.qml
INFO: Launching config: "/home/admin/programming/outfoxxed/quickshell/test/webengine.qml"
INFO: Shell ID: "4f1e843a16fb03d1e777938d3f1d5a86" Path ID "4f1e843a16fb03d1e777938d3f1d5a86"
INFO: Saving logs to "/run/user/1000/quickshell/by-id/9do3mwugbt/log.qslog"
DEBUG: Loaded library Qt6WebEngineQuick
DEBUG: Found symbol QtWebEngineQuick::initialize(). Initializing WebEngine...
DEBUG: Successfully initialized QtWebEngineQuick
INFO: Configuration Loaded
Received signal 11 SEGV_MAPERR 00000000001a
#0 0x7fdbd0692085 base::debug::CollectStackTrace()
#1 0x7fdbd0677d74 base::debug::StackTrace::StackTrace()
#2 0x7fdbd06927da base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7fdbde841da0 (/nix/store/j193mfi0f921y0kfs8vjc1znnr45ispv-glibc-2.40-66/lib/libc.so.6+0x41d9f)
#4 0x7fdbd058d965 base::internal::BindStateHolder::IsCancelled()
#5 0x7fdbd061bf75 base::sequence_manager::internal::TaskQueueImpl::RemoveAllCanceledDelayedTasksFromFront()
#6 0x7fdbd062df9c base::sequence_manager::internal::WakeUpQueue::RemoveAllCanceledDelayedTasksFromFront()
#7 0x7fdbd061590c base::sequence_manager::internal::SequenceManagerImpl::GetPendingWakeUp()
#8 0x7fdbd062fc95 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl()
#9 0x7fdbd0630ab2 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
#10 0x7fdbcb2cf02a std::_Function_handler<>::_M_invoke()
#11 0x7fdbdf21ed55 QObject::event()
#12 0x7fdbdf1be6a8 QCoreApplication::notifyInternal2()
#13 0x7fdbdf1c1f19 QCoreApplicationPrivate::sendPostedEvents()
#14 0x7fdbdf4fc92f postEventSourceDispatch()
#15 0x7fdbe190182b g_main_context_dispatch_unlocked
#16 0x7fdbe1904e08 g_main_context_iterate_unlocked.isra.0
#17 0x7fdbe19056af g_main_context_iteration
#18 0x7fdbdf4fc10d QEventDispatcherGlib::processEvents()
#19 0x7fdbdf1cc1eb QEventLoop::exec()
#20 0x7fdbdf1c7599 QCoreApplication::exec()
#21 0x559a4c8b5fd0 qs::launch::launch()
#22 0x559a4c8aa8db qs::launch::(anonymous namespace)::launchFromCommand()
#23 0x559a4c8a8735 qs::launch::runCommand()
#24 0x559a4c8a1663 qs::launch::main()
#25 0x7fdbde82a4c5 __libc_start_call_main
#26 0x7fdbde82a578 __libc_start_main_alias_2
#27 0x559a4c89ef45 _start
r8: 0000000000000000 r9: 0000000000000000 r10: 0000000000000000 r11: 0000000000000000
r12: 00007fff63b524e0 r13: 00007fff63b524e0 r14: 00007fff63b524e0 r15: 00007fdbacdf6f00
di: 0000000000000002 si: 0000000000000000 bp: 00007fff63b52050 bx: 00007fdbacdf7e00
dx: 0000000000000000 ax: 0000000000000000 cx: 0000000000000000 sp: 00007fff63b51a18
ip: 00007fdbd058d965 efl: 0000000000010246 cgf: 002b000000000033 erf: 0000000000000004
trp: 000000000000000e msk: 0000000000000000 cr2: 000000000000001a
[end of stack trace]
For
//@ pragma EnableQtWebEngineQuick
import Quickshell
import QtQuick
import QtWebEngine
FloatingWindow {
WebEngineView {
anchors.fill: parent
url: "https://www.qt.io"
}
}
I had run into the same issue, had to compile quickshell without jemalloc to fix it.
Disabling jemalloc does fix it but we don't want to do that generally. Does QtWebView have the same problem? Any particular reason we're using WebEngine here?
QtWebView also crashes for me without jemalloc disabled.
Unfortunate. Well we can probably merge this off by default.
Are you gonna merge this?
Since this week I finally have some free time again and will look into the issue myself and additionally the code for webengine over the week to try and determine a possible cause and ideally fix for it. But since this is an optional feature we might for now simply print a warning in the terminal that the feature is currently considered unstable and could crash
Hello just-some-entity, I've been working on WebEngine integration in my own fork and hit the same jemalloc issue. I can help address the remaining review feedback (style fixes, jemalloc warning, manual test QML). Would you be open to a PR against your webview branch, or would you prefer I post suggestions here? Thanks, T
@outfoxxed just wondering whether if this is getting merged to main branch or not
I really hope to see this pull request merged. Having a webview engine can further enrich the DMS plugin system and support more existing web components and designs
@ParticleG Feel free to check out this fork, reimplement it with latest (https://github.com/mecattaf/quickshellX) It works, if you happen to be on fedora i also have a cop where I package it: `harnessRPM/quickshellX)
~whats even qArgc for~ why not pass a pragma for its toggle
@ParticleG Feel free to check out this fork, reimplement it with latest (https://github.com/mecattaf/quickshellX) It works, if you happen to be on fedora i also have a cop where I package it: `harnessRPM/quickshellX)
@mecattaf It works. I'm using Arch with DMS shell + Niri as WM environment, and I wrote 3 different DMS plugins and they all worked well with your QuickshellX fork.
Here's my test plugins with QuickshellX sideload setup script and cleanup script: https://github.com/ParticleG/dms-webview-plugins