probonopd / linuxdeployqt

Makes Linux applications self-contained by copying in the libraries and plugins that the application uses, and optionally generates an AppImage. Can be used for Qt and other applications
Other
2.22k stars 414 forks source link

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

Open mgautierfr opened 2 years ago

mgautierfr commented 2 years ago

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

caralu74 commented 2 years ago

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

probonopd commented 2 years ago

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.

mgautierfr commented 2 years ago

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.

probonopd commented 2 years ago

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

mgautierfr commented 2 years ago

No warning, but same behavior (blank window)

probonopd commented 2 years ago

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?

mgautierfr commented 2 years ago

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 commented 2 years ago

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

probonopd commented 2 years ago

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

mishafuod-13 commented 2 years ago

@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 commented 2 years ago

@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.

kelson42 commented 2 years ago

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

mishafuod-13 commented 2 years ago

@kelson42 Glad if I could help :)

mgautierfr commented 2 years ago

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

caralu74 commented 1 year ago

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

martinrotter commented 1 year ago

I confirm the workaround to work. Thank you!

darealshinji commented 1 year ago

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.

SevenBlocks commented 1 year ago

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.

probonopd commented 1 year ago

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