diff --git a/dashboard/qml/Main.qml b/dashboard/qml/Main.qml index 5a1ae841..10d21ad1 100644 --- a/dashboard/qml/Main.qml +++ b/dashboard/qml/Main.qml @@ -25,6 +25,21 @@ Kirigami.ApplicationWindow { icon.source: Qt.resolvedUrl("wivrn.svg") onActivated: root.visible = !root.visible } + + Component{ + id: error_template + Kirigami.InlineMessage{ + visible: true + property string where + property string message + + Layout.fillWidth: true + text: where + (where ? "\n" : "") + message + type: Kirigami.MessageType.Error + showCloseButton: true + } + } + onClosing: Qt.quit() Core.Settings { @@ -72,18 +87,21 @@ Kirigami.ApplicationWindow { switch_pairing.checked = WivrnServer.pairingEnabled; } - // function onHeadsetConnectedChanged(value) { - // if (value != root.prev_headset_connected) { - // root.prev_headset_connected = value; - // - // if (value && root.pageStack.depth == 1) - // root.pageStack.push(Qt.resolvedUrl("HeadsetStatsPage.qml")); - // } - // } - function onJsonConfigurationChanged() { config.load(WivrnServer); } + + function onServerError(info) { + console.log(info.where); + console.log(info.message); + messages.append(error_template.createObject( + null, + { + where: info.where, + message: info.message + } + )); + } } Component.onCompleted: { @@ -102,107 +120,102 @@ Kirigami.ApplicationWindow { pageStack.initialPage: Kirigami.ScrollablePage { ColumnLayout { anchors.fill: parent - Kirigami.InlineMessage { - Layout.fillWidth: true - text: i18n("The server does not have CAP_SYS_NICE capabilities.") - // type: Kirigami.MessageType.Warning - type: Kirigami.MessageType.Information - showCloseButton: true - visible: !WivrnServer.capSysNice - actions: [ - Kirigami.Action { - text: i18n("Fix it") - onTriggered: WivrnServer.grant_cap_sys_nice() + Repeater{ + model: ObjectModel { + id: messages + Kirigami.InlineMessage { + Layout.fillWidth: true + text: i18n("The server does not have CAP_SYS_NICE capabilities.") + // type: Kirigami.MessageType.Warning + type: Kirigami.MessageType.Information + showCloseButton: true + visible: !WivrnServer.capSysNice + actions: [ + Kirigami.Action { + text: i18n("Fix it") + onTriggered: WivrnServer.grant_cap_sys_nice() + } + ] } - ] - } - Kirigami.InlineMessage { - Layout.fillWidth: true - text: i18n("Firewall may not allow port 9757.") - type: Kirigami.MessageType.Warning - showCloseButton: true - visible: Firewall.needSetup - actions: [ - Kirigami.Action { - text: i18n("Fix it") - onTriggered: Firewall.doSetup() + Kirigami.InlineMessage { + Layout.fillWidth: true + text: i18n("Firewall may not allow port 9757.") + type: Kirigami.MessageType.Warning + showCloseButton: true + visible: Firewall.needSetup + actions: [ + Kirigami.Action { + text: i18n("Fix it") + onTriggered: Firewall.doSetup() + } + ] } - ] - } - Kirigami.InlineMessage { - id: restart_capsysnice - Layout.fillWidth: true - text: i18n("The CAP_SYS_NICE capability will be used when the server is restarted.") - type: Kirigami.MessageType.Information - showCloseButton: true - visible: false - actions: [ - Kirigami.Action { - text: i18nc("restart the server", "Restart now") - onTriggered: { - WivrnServer.restart_server(); - restart_capsysnice.visible = false; - } + Kirigami.InlineMessage { + id: restart_capsysnice + Layout.fillWidth: true + text: i18n("The CAP_SYS_NICE capability will be used when the server is restarted.") + type: Kirigami.MessageType.Information + showCloseButton: true + visible: false + actions: [ + Kirigami.Action { + text: i18nc("restart the server", "Restart now") + onTriggered: { + WivrnServer.restart_server(); + restart_capsysnice.visible = false; + } + } + ] } - ] - } - Kirigami.InlineMessage { - Layout.fillWidth: true - text: i18n("NVIDIA GPUs require at least driver version 565.77, current version is %1", VulkanInfo.driverVersion) - type: Kirigami.MessageType.Error - showCloseButton: true - visible: VulkanInfo.driverId == "NvidiaProprietary" && VulkanInfo.driverVersionCode < 2371043328 /* Version 565.77 */ - actions: [ - Kirigami.Action { - text: i18n("More info") - onTriggered: Qt.openUrlExternally("https://github.com/WiVRn/WiVRn/issues/180") + Kirigami.InlineMessage { + Layout.fillWidth: true + text: i18n("NVIDIA GPUs require at least driver version 565.77, current version is %1", VulkanInfo.driverVersion) + type: Kirigami.MessageType.Error + showCloseButton: true + visible: VulkanInfo.driverId == "NvidiaProprietary" && VulkanInfo.driverVersionCode < 2371043328 /* Version 565.77 */ + actions: [ + Kirigami.Action { + text: i18n("More info") + onTriggered: Qt.openUrlExternally("https://github.com/WiVRn/WiVRn/issues/180") + } + ] } - ] - } - Kirigami.InlineMessage { - Layout.fillWidth: true - text: i18n("Use the Mesa (radv) driver for AMD GPUs\nHardware encoding with vaapi does not work with AMDVLK and AMDGPU-PRO") - type: Kirigami.MessageType.Warning - showCloseButton: true - visible: VulkanInfo.driverId == "AmdProprietary" || VulkanInfo.driverId == "AmdOpenSource" - } - - Kirigami.InlineMessage { - Layout.fillWidth: true - text: i18n("No OpenVR compatibility detected, Steam games won't be able to load VR.\nInstall xrizer or OpenComposite.") - type: Kirigami.MessageType.Warning - showCloseButton: true - visible: WivrnServer.openVRCompat.length == 0 && config.openvr == "" - } - - Kirigami.InlineMessage { - id: message_failed_to_start - Layout.fillWidth: true - text: i18n("Server failed to start") - type: Kirigami.MessageType.Error - showCloseButton: true - // visible: WivrnServer.serverStatus == WivrnServer.FailedToStart - actions: [ - Kirigami.Action { - text: i18n("Open server logs") - onTriggered: WivrnServer.open_server_logs() + Kirigami.InlineMessage { + Layout.fillWidth: true + text: i18n("Use the Mesa (radv) driver for AMD GPUs\nHardware encoding with vaapi does not work with AMDVLK and AMDGPU-PRO") + type: Kirigami.MessageType.Warning + showCloseButton: true + visible: VulkanInfo.driverId == "AmdProprietary" || VulkanInfo.driverId == "AmdOpenSource" } - ] - } - // RowLayout { - // Controls.Button { - // text: "refresh latest version" - // onClicked: ApkInstaller.refreshLatestVersion() - // } - // Controls.Label { - // text: "current version " + ApkInstaller.currentVersion + "\nlatest version " + ApkInstaller.latestVersion - // } - // } + Kirigami.InlineMessage { + Layout.fillWidth: true + text: i18n("No OpenVR compatibility detected, Steam games won't be able to load VR.\nInstall xrizer or OpenComposite.") + type: Kirigami.MessageType.Warning + showCloseButton: true + visible: WivrnServer.openVRCompat.length == 0 && config.openvr == "" + } + + Kirigami.InlineMessage { + id: message_failed_to_start + Layout.fillWidth: true + text: i18n("Server failed to start") + type: Kirigami.MessageType.Error + showCloseButton: true + // visible: WivrnServer.serverStatus == WivrnServer.FailedToStart + actions: [ + Kirigami.Action { + text: i18n("Open server logs") + onTriggered: WivrnServer.open_server_logs() + } + ] + } + } + } GridLayout { columns: 2 diff --git a/dashboard/wivrn_server.cpp b/dashboard/wivrn_server.cpp index f03639ec..86b46c94 100644 --- a/dashboard/wivrn_server.cpp +++ b/dashboard/wivrn_server.cpp @@ -257,6 +257,7 @@ void wivrn_server::on_server_dbus_registered() server_properties_interface = std::make_unique("io.github.wivrn.Server", "/io/github/wivrn/Server", QDBusConnection::sessionBus(), this); connect(server_properties_interface.get(), &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, &wivrn_server::on_server_properties_changed); + connect(server_interface.get(), &IoGithubWivrnServerInterface::ServerError, [this](const QString & w, const QString & m) { serverError(serverErrorData(w, m)); }); serverStatusChanged(m_serverStatus = Status::Started); refresh_server_properties(); diff --git a/dashboard/wivrn_server.h b/dashboard/wivrn_server.h index 7e4a1154..9d4d1c85 100644 --- a/dashboard/wivrn_server.h +++ b/dashboard/wivrn_server.h @@ -122,6 +122,23 @@ public: } }; +class serverErrorData +{ + Q_GADGET + QML_VALUE_TYPE(serverError) + + Q_PROPERTY(QString where MEMBER m_where CONSTANT) + Q_PROPERTY(QString message MEMBER m_message CONSTANT) + + QString m_where; + QString m_message; + +public: + serverErrorData() = default; + serverErrorData(QString where, QString message) : + m_where(where), m_message(message) {} +}; + class wivrn_server : public QObject { Q_OBJECT @@ -380,4 +397,5 @@ Q_SIGNALS: void supportedCodecsChanged(QStringList); void steamCommandChanged(QString); void serverLogsChanged(QString); + void serverError(serverErrorData); }; diff --git a/dbus/io.github.wivrn.Server.xml b/dbus/io.github.wivrn.Server.xml index 886746d1..e53d17fd 100644 --- a/dbus/io.github.wivrn.Server.xml +++ b/dbus/io.github.wivrn.Server.xml @@ -73,5 +73,10 @@ + + + + + diff --git a/server/driver/wivrn_comp_target.cpp b/server/driver/wivrn_comp_target.cpp index d3060ce5..7573c134 100644 --- a/server/driver/wivrn_comp_target.cpp +++ b/server/driver/wivrn_comp_target.cpp @@ -326,6 +326,10 @@ static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t prefer } catch (const std::exception & e) { + wivrn_ipc_socket_monado->send(from_monado::server_error{ + .where = "Error creating encoder", + .message = e.what(), + }); U_LOG_E("Failed to create video encoder: %s", e.what()); return false; } diff --git a/server/main.cpp b/server/main.cpp index 388a07c2..4f66361c 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -534,6 +534,9 @@ gboolean control_received(gint fd, GIOCondition condition, gpointer user_data) [&](const from_monado::bitrate_changed & value) { wivrn_server_set_bitrate(dbus_server, value.bitrate_bps); }, + [&](const from_monado::server_error & e) { + wivrn_server_emit_server_error(dbus_server, e.where.c_str(), e.message.c_str()); + }, }, *packet); } diff --git a/server/wivrn_ipc.h b/server/wivrn_ipc.h index cd9c9f4a..1ca66dbc 100644 --- a/server/wivrn_ipc.h +++ b/server/wivrn_ipc.h @@ -47,12 +47,19 @@ struct bitrate_changed uint32_t bitrate_bps; }; +struct server_error +{ + std::string where; + std::string message; +}; + using packets = std::variant< wivrn::from_headset::headset_info_packet, wivrn::from_headset::start_app, headset_connected, headset_disconnected, - bitrate_changed>; + bitrate_changed, + server_error>; } // namespace from_monado namespace to_monado