linuxdeploy / linuxdeploy-plugin-qt

Qt plugin for linuxdeploy, bundling Qt resources, plugins, QML files and a lot more.
https://github.com/linuxdeploy/linuxdeploy
MIT License
105 stars 37 forks source link

No QtWebEngineProcess executable bundled #112

Open danryu opened 2 years ago

danryu commented 2 years ago

Building an app with Qt 6.2.4 (installed via apt) on Ubuntu 22.04.

The app includes a single webview QML type, for which I need webengine to display the content.

If I set QML_SOURCES_PATHS to the directory containing the qml files, it doesn't seem to pick it up. If I manually copy the qml file into APPDIR, it does get picked up.

See the full build log here: https://gist.github.com/danryu/489f5307972c803b5364f8002d14d362

The apps builds and runs otherwise OK, but when executed produces the error:

No WebView plug-in found!

As expected, the webview just shows a white frame and doesn't render any content.

So I believe I just need QT_DIR/gcc_64/libexec/QtWebEngineProcess to be bundled, and it should work. How can I do this? I tried each of the following without effect.

export EXTRA_QT_PLUGINS=webengine
export EXTRA_QT_PLUGINS=webenginecore
export EXTRA_QT_PLUGINS=webview;
TheAssassin commented 2 years ago

There is a webengine deployer available. However, for Qt 6, it is not used yet.

PRs welcome testing and enabling this deployer.

danryu commented 2 years ago

Thanks @TheAssassin : I forked, patched simply as you suggested here, and rebuilt - see builds here.

When I build the app locally (with Qt 6.3.0 installed from aqtinstall), QtWebEngineProcess executable is now being deployed together with various other resources. Local build log here: https://gist.github.com/danryu/43b126c5e22c435469d773f0281de4c5

However I still get the error

No WebView plug-in found!

on running the appimage, and no web content rendered in the webview. I feel I must be very close now - and there's just one last thing to be hooked up.... Any ideas?

I also have my app building in CI, for Windows, Mac, Android, iOS and Linux. See the Linux appimage autobuild run here: https://github.com/koord-live/koord-realtime/runs/6791111736

For some reason, webenginecore is not listed in the Found Qt modules output during the CI run, and no QtWebEngineProcess resources are deployed. The only difference I have to my partially-successful local build is that the CI build is using Qt 6.2.4 from Jammy apt.

Unfortunately I am severely limited on time on this project, and current project scope means I have precious little time for debugging this issue now, as I am building for 5 platforms, and only Linux is presenting this issue. Note: For the Windows build, QtWebEngineProcess.exe is being deployed and executed successfully. The other builds (macOS, Android, iOS) all default to native runtimes and so this is not an issue there.

Any further help is super welcome.

danryu commented 2 years ago

Update: the webengine deployer seems to be running fine (in theory) with Qt 6.3.0. I updated the CI to install Qt 6.3.0 using aqtinstall on Ubuntu 20.04. The AppImage build runs fine, and executes nicely.

https://github.com/koord-live/koord-realtime/runs/6795585080

Still no WebView plugin though :)

No WebView plug-in found!

@TheAssassin Can you see anything in the job run which looks suspicious? AFAICT this should be working now.

TheAssassin commented 2 years ago

WebView plugin is related to QML, isn't it? The QML deployer indeed deploys appdir_gui/usr/qml/QtWebView/libqtwebviewquickplugin.so, so I suppose some additional work needs to be done. The list of modules is core dbus gui network opengl qml qmlmodels quick quickwidgets webenginecore widgets xml, so I guess we need a webview deployer.

Unfortunately, I have zero experience with webviews in Qt in general, and don't really use QML. Could you provide the file tree of the deployed Windows setup? Maybe that gives us some hints on what we need to change. In case it deploys a qt.conf, I'd further like to see its contents. (You can also just provide a link to some build, and I'll try to find time to extract that myself then.)

danryu commented 2 years ago

I posted the full Windows build log here: https://gist.github.com/danryu/4df440fc3365b97413c3329da5b566d6

You can see all the files included from line 7631 onwards. I hope this is good enough? No qt.conf anywhere as far as I can tell.

(As it happens, I have to copy the actual QtWebEngineProcess.exe manually, as that itself doesn't seem to get picked up.)

The bit of Powershell script which runs the windeployqt command is as such:

Invoke-Native-Command -Command "$Env:QtWinDeployPath" `
        -Arguments ("--$BuildConfig", "--no-compiler-runtime", "--dir=$DeployPath\$BuildArch", `
        "--no-system-d3d-compiler", "--qmldir=$RootPath\src", `
        "-webenginecore", "-webenginewidgets", "-webview", "-qml", "-quick", `
        "$BuildPath\$BuildConfig\$AppName.exe")

Move-Item -Path "$BuildPath\$BuildConfig\$AppName.exe" -Destination "$DeployPath\$BuildArch" -Force
TheAssassin commented 2 years ago

I could imagine that

a) the plugin lib cannot be found/loaded b) the executable cannot be found

The question is which one it is. Running strace on the bundle will probably help. As mentioned before, I'll try to find some time soon.

danryu commented 2 years ago

Thanks, I'd be very grateful for any update on this. linuxdeploy (with plugins) seems to be the most effective and intuitive method for generating appimage (I've tried a few), and I'd like it to be the "one-stop-shop" for all my Linux builds going forward...

trumpton commented 2 years ago

@danryu I've downloaded your version of the AppImage fork, and for me, it worked fine - the AppImage has a libexec and a resources folder, and the resulting AppImage runs OK (with regards to this concern).

I've a brand new installation of Ubuntu 22 (as of 4 days ago), and a brand new installation of Qt (not the Ubuntu bundled version).

I've created the AppImage with the version 6.2.4 LTS. Steve

echo "Building AppImage for ${APP_NAME}"

# QtWebEngineProcess - not currently supported (12/6/2022)
# https://github.com/linuxdeploy/linuxdeploy-plugin-qt/issues/112
# so alternative linuxdeploy-plugin-qt is used
# https://github.com/koord-live/linuxdeploy-plugin-qt/releases

${LINUXDEPLOY_BIN} \
        --desktop-file "src/appimage/${APP_NAME}.desktop" \
        --icon-file "src/appimage/${APP_NAME}.png" \
        --exclude-library "*libnss*" \
        --appdir "${APPIMG_BUILD_DIR}" \
        --executable "${BUILD_DIR}/${APP_NAME}" \
        --plugin qt

# libnss causes problems, so is unbundled
# note: the exclude-library is not passes to the qt plugin
# so this step is done by hand

/bin/rm -f ${APPIMG_BUILD_DIR}/usr/lib/libnss*

# Copy application-specific data files from src/share to appimage/share/appname

mkdir -p "${APPIMG_BUILD_DIR}/share/${APP_NAME}"
cp -R "src/share/*" "${APPIMG_BUILD_DIR}/share/${APP_NAME}"

# Now create the output image

${LINUXDEPLOY_BIN} \
        --appdir "${APPIMG_BUILD_DIR}" \
        --exclude-library "*libnss*" \
        --output appimage
danryu commented 2 years ago

Thanks @trumpton, that sounds promising. I wonder if libnss has anything to do with my missing Webview plugin issue. I may have a more generic problem in my code causing this (though it runs fine on Windows). I'll update when I can test again.

TheAssassin commented 2 years ago

@danryu mind to file a PR? We can work on the fix then and merge it upstream eventually.

trumpton commented 2 years ago

@danryu - I suspect libnss is not your issue here. When I ran your linuxdeploy version of the app, my program started up; did not complain about WebView; showed my app; tried to show a web page; shut down because of the libnss problem. Once I removed the libnss files from the AppImage, the program worked with the OS installed ones. Apparrently libnss is fraught! Because your linuxdeploy app meant that the WebView error was no more for me, I believe your fix works fine with regards to this particular problem.

danryu commented 2 years ago

@TheAssassin PR here: https://github.com/linuxdeploy/linuxdeploy-plugin-qt/pull/113

@trumpton Thanks for the libnss tips. Yes, if the WebView/WebEngine combo is working for you on Linux - and actually rendering web content - then that shows the webengine deployer is fully operational.