protonscr

Qt application misbehavior

steamclosed reviewedruntime
ValveSoftware/steam-for-linux#3788 · opened 2015-04-07 by OmnipotentEntity · updated 2019-07-18 · 3 comments · github
OOmnipotentEntity 2015-04-07 github

I'm currently having difficulties with a very simple launcher application that's intended to display a webpage and have some buttons to launch a game. When you click a link inside of the launcher it is intended to simply launch your default webbrowser with the link, rather than accepting and handling navigation requests.

However, when launched via Steam, links fail to open in a new webbrowser. Exact behavior depends on the environment, I've had reports of copies of gvfs-open and xdg-open hanging, though on my environment it simply gives mouse indication that firefox is opening for a split second and does nothing (including no processes launched at all according to strace, possibly has something to do with KDE's message passing system, I don't know). Vexingly enough, there are also reports that it just works fine. And so I'm having quite a problem hammering down the exact reproduction parameters as a result.

I've managed to narrow down the issues to Steam modifying the LD_LIBRARY_PATH of the executable to use Steam's Linux platforms. I've bundled all of the libraries needed by the launcher with the launcher.

Here is a minimal reproducible guide:

main.cpp

#include <QApplication>
#include <QWebFrame>
#include <QDesktopServices>
#include <QNetworkRequest>
#include <QMessageBox>
#include <QWebView>

class WebPage : public QWebPage {
public:
  bool acceptNavigationRequest(QWebFrame*, const QNetworkRequest &request, NavigationType) {
    QDesktopServices::openUrl(request.url());
    return false;
  }
};

class WebView : public QWebView {
public:
  QWebView* createWindow(QWebPage::WebWindowType) {
    WebView* res = new WebView;
    WebPage* page = new WebPage;
    res->setPage(page);
    return res;
  }
};

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

  WebView v;
  v.load(QUrl("http://example.com/"));
  v.show();

  return a.exec();
}

launcher.pro

QT += core gui network webkitwidgets widgets

TARGET = launcher
TEMPLATE = app

SOURCES = main.cpp

You will also need to copy and bundle the following libraries (standard Qt deployment):

libQt5Widgets.so libQt5Gui.so libQt5Core.so libQt5Network.so libQt5WebKitWidgets.so libQt5WebKit.so libQt5MultimediaWidgets.so libQt5OpenGL.so libQt5PrintSupport.so libQt5Multimedia.so libQt5Sensors.so libQt5Quick.so libQt5Qml.so libQt5Sql.so libQt5Positioning.so libQt5DBus.so libicui18n.so libicuuc.so libicudata.so libssl.so libcrypto.so libstdc++.so libgcc_s.so

And in a subdirectory called platforms:

libqxcb.so

And then finally a script to tie it together:

launch_launcher.sh

#!/bin/sh -e

cd "$(dirname "$0")"

LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./launcher

Finally, have steam installed and set it's LD_LIBRARY_PATH as your own and export it and run launch_launcher.sh (these exact paths depends on your steam installation.)

Essentially, if you remove $LD_LIBRARY_PATH from the launch_launcher script so that the line reads only LD_LIBRARY_PATH=. ./launcher then the links work. However with $LD_LIBRARY_PATH enabled links do not work. We need $LD_LIBRARY_PATH working in order to use the Steam Linux platform libraries (which makes the game work.)

Kkisak-valve maintainer 2018-07-20 github

Hello @OmnipotentEntity, are you still experiencing this issue on an up to date system? Steam has changed its behavior to prefer the system's libraries by default which may have resolved this issue for most users.

Kkisak-valve maintainer 2018-08-24 github

Closing pending feedback.

OOmnipotentEntity 2018-09-17 github

@kisak-valve I am no longer working for the same company anymore. I do not have a way to test this issue. I'm certain that the myriad change that have occurred in the past 3.5 years have invalidated this issue. Thanks for following up.

Nothing extracted yet.