linuxdeployqt icon indicating copy to clipboard operation
linuxdeployqt copied to clipboard

WebEngine display blank window when appimage is run on recent distribution (fix inside)

Open mgautierfr opened this issue 1 year ago • 19 comments

The original issue is for the kiwix project with issue : https://github.com/kiwix/kiwix-desktop/issues/810

This issue presents a small repro case and avoid all the kiwix full project : sample_qtwebengine.zip

The program is really simple, it is a QWebEngine with a "Hello, World!" text.

#include <QtGlobal>
#include <QApplication>
#include <QWebEngineView>


int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWebEngineView view;
    view.setHtml("<html><body>Hello, World!</body></html>");
    view.resize(1024, 750);
    view.show();

    return app.exec();
}

The application is packaged with qt515 found in ppa https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.15.2-bionic This is necessary as QtWebEngine is not packaged by Ubuntu bionic and we "need" bionic because of what described in https://github.com/probonopd/linuxdeployqt/issues/340

README.txt file explains how to compile the sample program (mostly qmake/make)

Appimage is generated using create_app_image.sh script in the archive. It mostly prepare AppDir, download last linuxdeployqt and run it to create appimage.

When generated AppImage is run on Ubuntu bionic, the webview display "Hello, World!". When run on recent distribution (Fedora, Ubuntu 20.04, other?), the AppImage launch but webview is empty. An Appimage generated on a recent distribution (with system qtWebEngine and option -unsupported-allow-new-glibc) works.

I've tried to compare strace log, between a run on Bionic and Fedora 36, but haven't found anything useful (at least for me) Same when comparing the content of AppImage generated on Bionic and Fedora 36

mgautierfr avatar Sep 13 '22 13:09 mgautierfr

I've got this: ~/sample_qtwebengine$ qmake Info: creating stash file /home/user/sample_qtwebengine/.qmake.stash user@PC_X:~/sample_qtwebengine$ make g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WEBENGINEWIDGETS_LIB -DQT_WEBENGINECORE_LIB -DQT_QUICK_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_WEBCHANNEL_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_POSITIONING_LIB -DQT_CORE_LIB -I. -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWebEngineWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtWebEngineCore -I/usr/include/x86_64-linux-gnu/qt5/QtQuick -I/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtQmlModels -I/usr/include/x86_64-linux-gnu/qt5/QtWebChannel -I/usr/include/x86_64-linux-gnu/qt5/QtQml -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtPositioning -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o main.o src/main.cpp g++ -Wl,-O1 -Wl,-rpath-link,/usr/lib/x86_64-linux-gnu -o sample_qtwebengine main.o /usr/lib/x86_64-linux-gnu/libQt5WebEngineWidgets.so /usr/lib/x86_64-linux-gnu/libQt5WebEngineCore.so /usr/lib/x86_64-linux-gnu/libQt5Quick.so /usr/lib/x86_64-linux-gnu/libQt5PrintSupport.so /usr/lib/x86_64-linux-gnu/libQt5Widgets.so /usr/lib/x86_64-linux-gnu/libQt5Gui.so /usr/lib/x86_64-linux-gnu/libQt5QmlModels.so /usr/lib/x86_64-linux-gnu/libQt5WebChannel.so /usr/lib/x86_64-linux-gnu/libQt5Qml.so /usr/lib/x86_64-linux-gnu/libQt5Network.so /usr/lib/x86_64-linux-gnu/libQt5Positioning.so /usr/lib/x86_64-linux-gnu/libQt5Core.so -lGL -lpthread
user@PC_X:~/sample_qtwebengine$ ./sample_qtwebengine

$ ./create_app_image.sh linuxdeployqt (commit 5fa79fa), build 36 built on 2022-08-21 12:36:03 UTC ERROR: The host system is too new. Please run on a system with a glibc version no newer than what comes with the oldest currently still-supported mainstream distribution (Ubuntu Bionic), which is glibc 2.27. This is so that the resulting bundle will work on most still-supported Linux distributions. For more information, please see https://github.com/probonopd/linuxdeployqt/issues/340

caralu74 avatar Oct 01 '22 21:10 caralu74

When generated AppImage is run on Ubuntu bionic, the webview display "Hello, World!". When run on recent distribution (Fedora, Ubuntu 20.04, other?), the AppImage launch but webview is empty.

Do you get any errors when launched from the comand line?

unsupported-...

It is unsupported and broken, don't use it.

probonopd avatar Oct 03 '22 09:10 probonopd

Do you get any errors when launched from the comand line?

Only a warning : Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.

It is unsupported and broken, don't use it.

Yes, it was just to say that a same application generated on a recent platform works. (but I need to use the unsupported option). The issue is about a appImage generated on a supported platform.

mgautierfr avatar Oct 04 '22 12:10 mgautierfr

Please try on a system without Wayland. Does it work there?

probonopd avatar Oct 04 '22 18:10 probonopd

No warning, but same behavior (blank window)

mgautierfr avatar Oct 05 '22 07:10 mgautierfr

Thanks for testing. Unfortunately I don't know the cause yet. Can you call your AppImage like this:

LD_DEBUG=libs ./YourApp-1.0.1-x86_64.AppImage

Do you see messages like

error: symbol lookup error: undefined symbol: ... (fatal)

or similar?

probonopd avatar Oct 05 '22 07:10 probonopd

Definitely I have some lookup error :

/tmp/.mount_SampleGmZP0r/usr/libexec/../lib/libQt5WebEngineCore.so.5: error: symbol lookup error: undefined symbol: localtime64 (fatal) /tmp/.mount_SampleGmZP0r/usr/libexec/../lib/libQt5WebEngineCore.so.5: error: symbol lookup error: undefined symbol: localtime64_r (fatal) ./Sample-0.0.1-x86_64.AppImage: error: symbol lookup error: undefined symbol: nspr_use_zone_allocator (fatal)

Full log is here: Sample-qtwebengine.log

mgautierfr avatar Oct 05 '22 07:10 mgautierfr

@probonopd Do you have a idea of what could be the problem here ? (apart that localtime64 is missing)

mgautierfr avatar Oct 19 '22 14:10 mgautierfr

Don't know (yet). More debugging is needed. Unfortunately I don't have the time to dive into this right now.

probonopd avatar Oct 19 '22 18:10 probonopd

@mgautierfr I faced a similar problem, but somehow I managed to overcome it by adding a couple of lines to main ():

qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-gpu --no-sandbox") ; QApplication::setAttribute(Qt::AA_UseOpenGLES);

Errors like the one you posted in this post, in my case, they appeared on different versions of Qt and did not play any role in rendering the web page.

mishafuod-13 avatar Oct 20 '22 16:10 mishafuod-13

@mgautierfr I tested the built Appimage (from your project 'sample_qtwebengine') with the options that I specified above on Fedora 35 (built on Ubuntu 18.04) - the render appeared.

mishafuod-13 avatar Oct 20 '22 20:10 mishafuod-13

@mishafuod-13 Seems to be a really valuable input of you. Thank you very much.

kelson42 avatar Oct 21 '22 06:10 kelson42

@kelson42 Glad if I could help :)

mishafuod-13 avatar Oct 22 '22 11:10 mishafuod-13

@mishafuod-13 I confirm the workaround. Thanks a lot !

mgautierfr avatar Nov 22 '22 15:11 mgautierfr

And for me is working fine. Good job, thanks!

caralu74 avatar Jan 03 '23 21:01 caralu74

I confirm the workaround to work. Thank you!

martinrotter avatar Jan 19 '23 07:01 martinrotter

I have the same issues when I try to bundle notepadqq. The mentioned workaround however doesn't do anything here. Build system is Ubuntu 20.04, host system is Ubuntu 23.04 (qtwebengine not being installed).

Update: nevermind, after a system reboot it seems to work now.

darealshinji avatar Apr 27 '23 18:04 darealshinji

I have the same issue building on Ubuntu 20.04 with Qt 6.6.0 and the above workaround does not help. The webviewer works when executing the binary with the Qt libs in the LD_LIBRARY_PATH, but it shows a blank screen when running the appimage created by linuxdeployqt, so I suspect linuxdeployqt is not including all the necessary libs. Possibly relevant terminal output: [1013/095916.194515:FATAL:v8_initializer.cc(516)] Error loading V8 startup snapshot file

SOLVED: linuxdeployqt was not copying .../Qt/6.6.0/gcc_64/resources/v8_context_snapshot.bin. Manually copying over this file solved my problem.

SevenBlocks avatar Oct 13 '23 17:10 SevenBlocks

So on Qt6 we need to also deploy resources/v8_context_snapshot.bin whenever WebEngine gets deployed?

probonopd avatar Oct 28 '23 11:10 probonopd