Compare commits

...
Author SHA1 Message Date
Vindicus999 59a765c877 Merge remote-tracking branch 'upstream/master' 2026-01-27 02:08:20 +00:00
Jonathan Steffan 97d6a19199 Merge pull request #743 from damaestro/add-debugging-docs
docs(debugging): add debugging documentation
2026-01-26 09:05:33 -07:00
Jonathan Steffan 254f32b262 docs(debugging): add debugging documentation 2026-01-25 18:33:31 -07:00
Patrick Nicolas c846cb1ed2 Don't force 10 bit for H.265 and AV1 2026-01-25 12:26:19 +01:00
Patrick Nicolas 20a81ed004 Add check for VAAPI 10 bit encoding 2026-01-25 12:21:50 +01:00
Vindicus999 a6b8301a73 Merge remote-tracking branch 'upstream/master' 2026-01-25 02:12:03 +00:00
Patrick Nicolas 6fcc19d198 Fix version for debian package in CI 2026-01-24 21:54:13 +01:00
Patrick Nicolas cd614c2361 Fix error for shortcuts with no icon 2026-01-24 15:20:32 +01:00
Patrick Nicolas 4831e8847d case insensitive comparison for vdf files 2026-01-24 15:16:20 +01:00
Vindicus999 94af0f5f55 Merge remote-tracking branch 'upstream/master' 2026-01-24 01:57:41 +00:00
Patrick Nicolas 2ee3306d6a Assign audio channel names for pipewire 2026-01-23 18:43:53 +01:00
Vindicus999 9cacea294c Merge remote-tracking branch 'upstream/master' 2026-01-22 02:05:16 +00:00
Patrick Nicolas 2893ab857d Remove force-quantum for mic as well 2026-01-21 18:22:32 +01:00
Patrick Nicolas 94457a566a Remove incorrect force-quantum value for pipewire 2026-01-21 13:07:00 +01:00
Patrick Nicolas 740b255461 Only read relevant info from appcache 2026-01-20 15:06:18 +01:00
Patrick Nicolas cc773294e3 Read non-Steam games using shortcuts.vdf 2026-01-20 14:05:06 +01:00
Patrick Nicolas 514c44b0a1 Log command launched through systemd units 2026-01-20 12:46:07 +01:00
Vindicus999 75da37bf6c Merge remote-tracking branch 'upstream/master' 2026-01-20 02:01:41 +00:00
Patrick Nicolas 5e4108f1c1 Don't build libnotify in flatpak 2026-01-19 23:23:18 +01:00
Patrick Nicolas 62a626e35e Avoid memory allocation in UDP receive 2026-01-19 21:41:04 +01:00
Patrick Nicolas e06d0d0943 Optimize away a memory allocation 2026-01-19 21:41:04 +01:00
Guillaume Meunier b632502da5 Fix missing starry background in nightly builds published on the Meta store 2026-01-19 21:40:34 +01:00
Patrick Nicolas 25a532bc15 Handle Path= argument in .desktop files 2026-01-19 10:40:37 +01:00
Vindicus999 7f849180f5 Merge remote-tracking branch 'upstream/master' 2026-01-19 02:06:44 +00:00
Patrick Nicolas 70adbafdc9 shared_ptr -> unique_ptr for audio handle 2026-01-18 16:23:17 +01:00
21 changed files with 881 additions and 214 deletions
+7 -3
View File
@@ -279,7 +279,6 @@ jobs:
VERSION_CODE=$(( $VERSION_CODE + 1 ))
fi
CSS=images/wivrn-release.css
APPNAME=WiVRn
else
VERSION_CODE=1
@@ -287,15 +286,20 @@ jobs:
if [ ${{ github.ref_type }} = 'tag' ]
then
SUFFIX=".github"
CSS=images/wivrn-release.css
APPNAME="WiVRn"
else
SUFFIX=".github.testing"
CSS=images/wivrn-nightly.css
APPNAME="WiVRn Testing"
fi
fi
if [ ${{ github.ref_type }} = 'tag' ]
then
CSS=images/wivrn-release.css
else
CSS=images/wivrn-nightly.css
fi
echo Setting version $VERSION and version code $VERSION_CODE in manifest
echo Using stylesheet $CSS and name $APPNAME
+38 -26
View File
@@ -75,11 +75,11 @@ std::string read_vr_manifest(const std::filesystem::path & root)
return read_file(root / "config/steamapps.vrmanifest");
}
steam_app_info read_steam_app_info(const std::filesystem::path & root)
std::unordered_map<uint32_t, wivrn::steam_icon> safe_read_steam_icons(const std::filesystem::path & root)
{
try
{
return steam_app_info{root / "appcache/appinfo.vdf"};
return read_steam_icons(root / "appcache/appinfo.vdf");
}
catch (...)
{}
@@ -87,14 +87,15 @@ steam_app_info read_steam_app_info(const std::filesystem::path & root)
return {};
}
std::optional<std::filesystem::path> find_steam_icon(const std::filesystem::path & root, int app_id, const steam_app_info & info)
std::optional<std::filesystem::path> find_steam_icon(const std::filesystem::path & root, int app_id, const std::unordered_map<uint32_t, wivrn::steam_icon> & info)
{
const auto & app_info = info.get(app_id);
auto icon = info.find(app_id);
if (icon == info.end())
return std::nullopt;
try
{
std::string icon{std::get<std::string_view>(app_info.at("common.clienticon"))};
auto icon_path = root / "steam/games" / (icon + ".ico");
auto icon_path = root / "steam/games" / (icon->second.clienticon + ".ico");
if (std::filesystem::exists(icon_path))
return icon_path;
@@ -105,10 +106,7 @@ std::optional<std::filesystem::path> find_steam_icon(const std::filesystem::path
try
{
std::string icon{std::get<std::string_view>(app_info.at("common.linuxclienticon"))};
auto icon_path = root / "steam/games" / (icon + ".zip");
auto icon_path = root / "steam/games" / (icon->second.linuxclienticon + ".zip");
if (std::filesystem::exists(icon_path))
return icon_path;
}
@@ -126,7 +124,7 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
return;
auto manifest = read_vr_manifest(*root);
auto info = read_steam_app_info(*root);
auto info = safe_read_steam_icons(*root);
if (manifest.empty())
return;
@@ -138,6 +136,11 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
{
application app;
if (i["launch_type"] == "url")
app.exec = command + " " + (std::string)i["url"];
else
continue;
std::string app_key = i["app_key"];
for (auto [locale, items]: i["strings"].items())
{
@@ -154,21 +157,6 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
app.name[""] = it->second;
}
if (i["launch_type"] == "url")
{
app.exec = command + " " + (std::string)i["url"];
}
else if (i["launch_type"] == "binary")
{
const char prefix[] = "steam.app.";
if (app_key.starts_with(prefix))
{
// ¯\_(ツ)_/¯
uint64_t appkey = stoll(app_key.substr(strlen(prefix)));
app.exec = command + " steam://rungameid/" + std::to_string((appkey << 32) + 0x2000000);
}
}
try
{
const char prefix[] = "steam.app.";
@@ -190,6 +178,30 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
std::cerr << "Failed to parse Steam VR manifest: " << e.what() << std::endl;
}
}
for (auto const & entry: std::filesystem::directory_iterator{*root / "userdata"})
{
auto shortcuts_vdf = entry.path() / "config/shortcuts.vdf";
if (std::filesystem::exists(shortcuts_vdf))
{
try
{
for (auto && item: read_steam_shortcuts(shortcuts_vdf))
{
res[std::to_string(item.appid)] = {
.name = {{"", std::move(item.name)}},
// ¯\_(ツ)_/¯
.exec = command + " steam://rungameid/" + std::to_string((uint64_t(item.appid) << 32) + 0x2000000),
.icon_path = std::move(item.icon),
};
}
}
catch (std::exception & e)
{
std::cerr << "Failed to parse Steam shortcuts file " << shortcuts_vdf << ": " << e.what() << std::endl;
}
}
}
}
std::string unescape(std::string_view in)
+190 -102
View File
@@ -18,169 +18,257 @@
#include "steam_app_info.h"
#include <bit>
#include <cctype>
#include <cstring>
#include <fstream>
#include <span>
#include <string_view>
#include <iostream>
namespace
{
template <typename T>
T read(std::span<char> & buffer);
template <typename T>
requires std::is_integral_v<T>
T read(std::span<char> & buffer)
class binary_reader
{
if (sizeof(T) > buffer.size())
throw std::runtime_error{"File truncated"};
std::ifstream in;
T value;
memcpy(&value, buffer.data(), sizeof(T));
buffer = buffer.subspan(sizeof(T));
public:
binary_reader(std::ifstream && in) : in{std::move(in)} {}
static_assert(std::endian::native == std::endian::big or std::endian::native == std::endian::little);
void discard(size_t bytes)
{
in.seekg(bytes, std::ios_base::cur);
}
if constexpr (std::endian::native == std::endian::big)
return std::byteswap(value);
else
return value;
}
template <typename T>
T read();
template <typename T>
requires std::is_integral_v<T>
T read()
{
T res;
in.read((char *)&res, sizeof(T));
if (not in)
throw std::runtime_error{"File truncated"};
static_assert(std::endian::native == std::endian::big or std::endian::native == std::endian::little);
if constexpr (std::endian::native == std::endian::big)
return std::byteswap(res);
else
return res;
}
std::vector<std::string> string_table();
auto tellg()
{
return in.tellg();
}
void seekg(size_t pos)
{
in.seekg(pos);
}
};
template <>
std::string_view read<std::string_view>(std::span<char> & buffer)
std::string binary_reader::read()
{
size_t size = strnlen((char *)buffer.data(), buffer.size());
if (size == buffer.size())
std::string res;
std::getline(in, res, '\0');
if (not in)
throw std::runtime_error{"File truncated"};
char * str = buffer.data();
buffer = buffer.subspan(size + 1);
return {str, size};
return res;
}
std::span<char> read(std::span<char> & buffer, size_t size)
std::vector<std::string> binary_reader::string_table()
{
if (size > buffer.size())
throw std::runtime_error{"File truncated"};
std::vector<std::string> res;
size_t string_offset = read<uint64_t>();
auto pos = in.tellg();
std::span<char> value{buffer.data(), size};
buffer = buffer.subspan(size);
return value;
in.seekg(string_offset);
auto count = read<uint32_t>();
res.reserve(count);
for (size_t i = 0; i < count; ++i)
res.emplace_back(read<std::string>());
in.seekg(pos);
return res;
}
std::vector<std::string_view> read_string_table(std::span<char> buffer)
template <typename T>
void read_dict(binary_reader & in, T & visitor, const std::vector<std::string> * string_table = nullptr)
{
std::vector<std::string_view> string_table;
uint32_t count = read<uint32_t>(buffer);
string_table.reserve(count);
for (size_t i = 0; i < count; i++)
string_table.emplace_back(read<std::string_view>(buffer));
return string_table;
}
void read_vdf(wivrn::steam_app_info::info & info, const std::string & prefix, std::span<char> & bindata, const std::vector<std::string_view> & string_table)
{
int type = read<uint8_t>(bindata);
while (type != 8)
while (true)
{
std::string name{string_table.at(read<uint32_t>(bindata))};
for (char & c: name)
c = std::tolower(c);
auto type = in.read<uint8_t>();
if (type == 8)
{
visitor.end_dict();
return;
}
// https://github.com/ValveResourceFormat/ValveKeyValue/blob/master/ValveKeyValue/ValveKeyValue/KeyValues1/KV1BinaryNodeType.cs
// Key
const std::string & key = string_table ? string_table->at(in.read<uint32_t>()) : in.read<std::string>();
// Value
switch (type)
{
case 0: // Dictionary
read_vdf(info, prefix + name + ".", bindata, string_table);
visitor.begin_dict(key);
read_dict(in, visitor, string_table);
break;
case 1: // UTF-8 string
info.emplace(prefix + name, read<std::string_view>(bindata));
visitor.on_string(key, in.read<std::string>());
break;
case 2: // uint32_t
info.emplace(prefix + name, read<uint32_t>(bindata));
visitor.on_uint32_t(key, in.read<uint32_t>());
break;
// case 3: // float
// break;
default:
throw std::runtime_error{"Unknown object type " + std::to_string(type)};
}
type = read<uint8_t>(bindata);
}
}
} // namespace
wivrn::steam_app_info::steam_app_info(std::filesystem::path path)
std::unordered_map<uint32_t, wivrn::steam_icon> wivrn::read_steam_icons(std::filesystem::path path)
{
std::vector<std::string_view> string_table;
binary_reader in{std::ifstream{path}};
{
std::ifstream f{path};
data = std::vector<char>{std::istreambuf_iterator{f}, {}};
}
std::span<char> buffer = data;
// See https://github.com/SteamDatabase/SteamAppInfo/blob/master/README.md#file-header
uint32_t magic = read<uint32_t>(buffer);
uint32_t magic = in.read<uint32_t>();
if ((magic & 0xff'ff'ff'00) != 0x07'56'44'00)
throw std::runtime_error{"Wrong magic number"};
auto universe = in.read<uint32_t>();
int version = magic & 0xff;
if (version < 41)
throw std::runtime_error{"Unsupported version"};
int universe = read<uint32_t>(buffer);
std::vector<std::string> string_table;
std::vector<std::string> * string_table_ptr = nullptr;
if (version >= 41)
{
size_t string_offset = read<uint64_t>(buffer);
string_table = read_string_table(std::span<char>{data}.subspan(string_offset));
string_table = in.string_table();
string_table_ptr = &string_table;
}
else
throw std::runtime_error{"Unsupported version"};
std::unordered_map<uint32_t, wivrn::steam_icon> res;
struct V
{
wivrn::steam_icon current{};
void begin_dict(const std::string & key)
{
}
void end_dict()
{
}
void on_string(const std::string & key, std::string && val)
{
if (strcasecmp(key.c_str(), "clienticon") == 0)
current.clienticon = std::move(val);
else if (strcasecmp(key.c_str(), "linuxclienticon") == 0)
current.linuxclienticon = std::move(val);
}
void on_uint32_t(const std::string & key, uint32_t val)
{
}
};
while (true)
{
// See https://github.com/SteamDatabase/SteamAppInfo/blob/master/README.md#app-entry-repeated
auto app_id = read<uint32_t>(buffer);
auto app_id = in.read<uint32_t>();
if (app_id == 0)
break;
auto size_data = read<uint32_t>(buffer);
char * current_offset = buffer.data();
read<uint32_t>(buffer); // info_state
read<uint32_t>(buffer); // last_updated
read<uint64_t>(buffer); // pics_token
read(buffer, 20); // SHA1 of the app info
read<uint32_t>(buffer); // change number
// if (version < 38)
// read<uint8_t>(buffer); // section type
read(buffer, 20); // SHA1 of the bin data
auto bindata = read(buffer, size_data - (buffer.data() - current_offset));
size_t size_data = in.read<uint32_t>();
size_t pos = in.tellg();
in.discard(
4 // info_state
+ 4 // last_updated
+ 8 // pics_token
+ 20 // SHA1 of the app info
+ 4 // change number
+ 20 // SHA1 of the bin data
+ 4 // checksum
+ 1 // type
);
try
{
bindata = bindata.subspan(4 + 1); // Skip the checksum + type (must be 0)
info app_info;
read_vdf(app_info, "", bindata, string_table);
app_data.emplace(app_id, app_info);
V v;
read_dict(in, v, string_table_ptr);
if (not(v.current.clienticon.empty() and v.current.linuxclienticon.empty()))
res.emplace(app_id, std::move(v.current));
}
catch (...)
{
// Ignore errors
}
in.seekg(pos + size_data);
}
return res;
}
std::vector<wivrn::steam_shortcut> wivrn::read_steam_shortcuts(std::filesystem::path path)
{
binary_reader in{std::ifstream{path}};
auto type = in.read<uint8_t>();
auto name = in.read<std::string>();
if (type != 0 or name != "shortcuts")
throw std::runtime_error{"Invalid type for shortcuts file"};
std::vector<wivrn::steam_shortcut> res;
struct V
{
std::vector<wivrn::steam_shortcut> & items;
int depth = 0;
wivrn::steam_shortcut current{};
bool VR = false;
void begin_dict(const std::string & key)
{
++depth;
if (depth == 1)
{
current = decltype(current){};
VR = false;
}
}
void end_dict()
{
--depth;
if (depth == 0)
{
if (VR)
items.push_back(std::move(current));
}
}
void on_string(const std::string & key, std::string && val)
{
if (depth == 1)
{
if (strcasecmp(key.c_str(), "AppName") == 0)
current.name = std::move(val);
else if (strcasecmp(key.c_str(), "icon") == 0 and not val.empty())
current.icon = std::move(val);
}
}
void on_uint32_t(const std::string & key, uint32_t val)
{
if (depth == 1)
{
if (strcasecmp(key.c_str(), "appid") == 0)
current.appid = val;
else if (strcasecmp(key.c_str(), "OpenVR") == 0)
VR = val;
}
}
} v{res};
read_dict(in, v);
return res;
}
+16 -22
View File
@@ -19,33 +19,27 @@
#pragma once
#include <filesystem>
#include <optional>
#include <unordered_map>
#include <variant>
#include <vector>
namespace wivrn
{
class steam_app_info
struct steam_icon
{
public:
using info = std::unordered_map<std::string, std::variant<uint32_t, std::string_view>>;
private:
std::vector<char> data;
std::unordered_map<int, info> app_data;
public:
steam_app_info(std::filesystem::path path);
steam_app_info() = default;
steam_app_info(const steam_app_info &) = delete;
steam_app_info(steam_app_info &&) = default;
steam_app_info & operator=(const steam_app_info &) = delete;
steam_app_info & operator=(steam_app_info &&) = default;
const auto & get(int appid) const
{
return app_data.at(appid);
}
std::string clienticon;
std::string linuxclienticon;
};
struct steam_shortcut
{
uint32_t appid;
std::string name;
std::optional<std::filesystem::path> icon;
};
std::unordered_map<uint32_t, steam_icon> read_steam_icons(std::filesystem::path path);
std::vector<steam_shortcut> read_steam_shortcuts(std::filesystem::path path);
} // namespace wivrn
+15 -15
View File
@@ -308,29 +308,29 @@ wivrn::deserialization_packet wivrn::UDP::receive_raw()
static const size_t message_size = 2048;
static const size_t num_messages = 20;
if ((not buffer) or buffer.use_count() > 1)
{
#if defined(__cpp_lib_smart_ptr_for_overwrite) && __cpp_lib_smart_ptr_for_overwrite >= 202002L
buffer = std::make_shared_for_overwrite<uint8_t[]>(message_size * num_messages);
buffer = std::make_shared_for_overwrite<uint8_t[]>(message_size * num_messages);
#else
buffer.reset(new uint8_t[message_size * num_messages]);
buffer.reset(new uint8_t[message_size * num_messages]);
#endif
std::vector<iovec> iovecs;
std::vector<mmsghdr> mmsgs;
iovecs.reserve(num_messages);
mmsgs.reserve(num_messages);
}
std::array<iovec, num_messages> iovecs;
std::array<mmsghdr, num_messages> mmsgs;
for (size_t i = 0; i < num_messages; ++i)
{
iovecs.push_back({
iovecs[i] = {
.iov_base = buffer.get() + message_size * i,
.iov_len = message_size,
});
};
mmsgs.push_back(
{
.msg_hdr = {
.msg_iov = &iovecs.back(),
.msg_iovlen = 1,
},
});
mmsgs[i] = {
.msg_hdr = {
.msg_iov = &iovecs[i],
.msg_iovlen = 1,
},
};
}
int received = recvmmsg(fd, mmsgs.data(), num_messages, MSG_DONTWAIT, nullptr);
+509
View File
@@ -0,0 +1,509 @@
# Debugging WiVRn
This guide covers debugging techniques for WiVRn, including log collection, crash analysis, performance profiling, and common troubleshooting scenarios.
## Table of Contents
- [Prerequisites](#prerequisites)
- [Collecting Logs](#collecting-logs)
- [HMD Client Logs](#hmd-client-logs)
- [Server Logs](#server-logs)
- [Starting Components for Debugging](#starting-components-for-debugging)
- [HMD Client](#hmd-client)
- [Server](#server)
- [XR Applications](#xr-applications)
- [Crash Debugging](#crash-debugging)
- [Server Crashes](#server-crashes)
- [HMD Client Crashes](#hmd-client-crashes)
- [Performance Debugging](#performance-debugging)
- [Timing Analysis](#timing-analysis)
- [Perfetto Profiling](#perfetto-profiling)
- [USB Tunneling](#usb-tunneling)
- [Game Debugging](#game-debugging)
- [Environment Variables Reference](#environment-variables-reference)
- [Configuration Files](#configuration-files)
- [External Resources](#external-resources)
- [Remote Native Debugging (Advanced)](#remote-native-debugging-advanced)
---
## Prerequisites
### ADB Setup
The Android Debug Bridge ([ADB](https://developer.android.com/tools/adb)) is required for debugging the HMD client. Connect your headset to your PC via a USB data cable and authorize the connection when prompted in the HMD.
### Clean Installation
When debugging, ensure the HMD client matches the server version. Perform a clean reinstall:
```bash
# Find and uninstall existing installation
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb uninstall ${WIVRN_PKG}
# Install the debug APK
adb install /path/to/wivrn-standard-debug.apk
```
---
## Collecting Logs
### HMD Client Logs
The primary method to collect logs from the HMD is through [ADB logcat](https://developer.android.com/tools/logcat).
Watch for crashes (FATAL priority):
```bash
adb logcat '*:F'
```
Record ERROR and above:
```bash
adb logcat '*:E' | tee -a errors-$(date "+%Y-%m-%d-%H").log
```
WiVRn-only logs (verbose):
```bash
adb logcat '*:S' WiVRn:V
```
Watch WiVRn client logs:
```bash
adb logcat | grep WiVRn
```
Watch Android system logs related to WiVRn:
```bash
adb logcat | grep wivrn
```
### Server Logs
Start the server with debug logging enabled:
```bash
XRT_LOG=debug XRT_COMPOSITOR_LOG=debug wivrn-server
```
To also dump video frames for analysis:
```bash
XRT_LOG=debug XRT_COMPOSITOR_LOG=debug WIVRN_DUMP_VIDEO=/tmp/video-dump wivrn-server
```
The video dump can be played back with `mpv` or other media players to verify what video was being sent to the HMD.
There will be multiple files in the directory, one for each video stream per codec. For example, `/tmp/video-dump-0.h264`.
---
## Starting Components for Debugging
### HMD Client
The package name varies by build variant:
- `org.meumeu.wivrn` - for app store builds
- `org.meumeu.wivrn.github` - for GitHub release builds
- `org.meumeu.wivrn.local` - for locally built APK
- `org.meumeu.wivrn.github.testing` - for CI runs
- `org.meumeu.wivrn.github.nightly` - for APK repo
Find your installed package with:
```bash
adb shell pm list packages | grep wivrn
```
Start via ADB:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb shell am start ${WIVRN_PKG}/org.meumeu.wivrn.MainActivity
```
Connect to a specific server:
Replace `ADDRESS=localhost` with the address of the server you want to connect to.
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
ADDRESS=localhost
adb shell am start -a android.intent.action.VIEW -d "wivrn://${ADDRESS}" ${WIVRN_PKG}
```
Stop the client:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb shell am force-stop ${WIVRN_PKG}
```
### Server
Start the server with debug logging:
```bash
XRT_LOG=debug XRT_COMPOSITOR_LOG=debug wivrn-server
```
The server will publish itself on the network via mDNS/Zeroconf for discovery by the HMD client.
### XR Applications
Basic OpenXR application:
```bash
xrgears
```
To run Steam games via OpenVR, make sure to add the Steam launch options presented by the server output or in the dashboard. This is required to configure the OpenVR runtime correctly.
Some games have options to control window behavior. Try adding `-windowed` or `-window -w 1280 -h 1024` to the game launch options to allow moving/resizing the local render window. Each game may have different options, check the game's documentation.
> Note: Games linked to OpenVR require [OpenComposite](https://gitlab.com/znixian/OpenOVR) or [xrizer](https://github.com/Supreeeme/xrizer) to translate calls to OpenXR.
---
## Crash Debugging
### Server Crashes
#### Systemd
Core dumps are managed by [systemd-coredump](https://www.freedesktop.org/software/systemd/man/latest/coredumpctl.html).
View the most recent crash:
```bash
coredumpctl info
```
Start a debugger on the most recent crash:
```bash
coredumpctl -1 debug
```
Inside GDB/LLDB:
```
# Select frame 2
f 2
# View local variables
info locals
# Print backtrace
bt
```
#### Non-Systemd Systems
On systems without systemd-coredump, core dumps are handled by the kernel directly.
Check where core dumps are written:
```bash
cat /proc/sys/kernel/core_pattern
```
To set a simple core pattern:
```bash
sudo sysctl -w kernel.core_pattern=/tmp/core.%e.%p.%t
```
This writes cores to `/tmp/` with the format `core.<executable>.<pid>.<timestamp>`.
Analyze a core dump with GDB:
```bash
gdb /usr/bin/wivrn-server /tmp/core.wivrn-server.12345.1706234567
```
Inside GDB:
```
# Print backtrace
bt
# View all threads
info threads
# Switch to thread 2
thread 2
# Print backtrace for all threads
thread apply all bt
```
### HMD Client Crashes
Copy the traceback from the HMD logs using logcat:
```bash
adb logcat '*:F' | grep -A 50 wivrn
```
---
## Performance Debugging
### Timing Analysis
WiVRn can record detailed timing information for analysis.
Capture timing data:
```bash
WIVRN_DUMP_TIMINGS=/tmp/wivrn-timings.csv wivrn-server
```
### Perfetto Profiling
[Perfetto](https://perfetto.dev/) provides detailed system-wide profiling.
#### HMD Profiling
Enable persistent tracing on Android:
```bash
adb shell setprop persist.traced.enable 1
```
Open the [Perfetto UI](https://ui.perfetto.dev/), connect to your device, and configure tracing as needed.
See the [Android tracing quickstart](https://perfetto.dev/docs/quickstart/android-tracing) for detailed instructions.
#### Server Profiling
Ensure WiVRn is built with `XRT_FEATURE_TRACING=ON` to enable [Monado tracing with Perfetto](https://monado.pages.freedesktop.org/monado/tracing-perfetto.html).
Start with tracing enabled:
```bash
XRT_TRACING=true wivrn-server
```
---
## USB Tunneling
For debugging network issues or testing with a wired connection, you can tunnel WiVRn over USB.
Set up the tunnel and connect:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb reverse tcp:9757 tcp:9757
adb shell am start -a android.intent.action.VIEW -d "wivrn+tcp://localhost:9757" ${WIVRN_PKG}
```
You are also able to make this connection through the dashboard.
---
## Game Debugging
### Proton/Wine Games
Enable additional logging for Windows compatibility layers:
```
PROTON_LOG=1 WINEDEBUG=vrclient,openxr,steam %command%
```
### OpenComposite
For games using OpenVR, and you are using [OpenComposite](https://gitlab.com/znixian/OpenOVR) to translate calls to OpenXR.
The OpenComposite log can be found at `$HOME/.local/state/OpenComposite/logs/opencomposite.log`.
### XRizer
To debug [xrizer](https://github.com/Supreeeme/xrizer), you can set the `RUST_LOG` environment variable to control the log level.
| Variable | Description | Default |
|------------|-----------------------------------------------------------------------------|---------|
| `RUST_LOG` | Configures the logging level for Rust applications. Accepts a comma-separated list of directives in the format `module::path=level`, where `level` can be `error`, `warn`, `info`, `debug`, or `trace`. For example, `RUST_LOG=info,my_crate=debug` sets the global level to `info` and the `my_crate` module to `debug`. | `warn` |
In xrizer, `RUST_LOG` follows the standard [`env_logger` semantics](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) described above. In addition, xrizer defines the following useful nonstandard logging targets:
| Logging Target | Description |
|-----------------|-------------|
| `openvr_calls` | Logs the name of each OpenVR function as they are called |
| `tracked_property` | Logs the name and device index of each requested tracked device property |
The log is located at `$XDG_STATE_HOME/xrizer/xrizer.txt`, or `$HOME/.local/state/xrizer/xrizer.txt` if `$XDG_STATE_HOME` is not set.
---
## Environment Variables Reference
### Compositor Settings
| Variable | Description | Default |
|----------|-------------|---------|
| `XRT_LOG` | Log level (`trace`, `debug`, `info`, `warn`, `error`) | `warn` |
| `XRT_COMPOSITOR_LOG` | Compositor log level (`trace`, `debug`, `info`, `warn`, `error`) | `info` |
| `OXR_VIEWPORT_SCALE_PERCENTAGE` | Per-application viewport scale (set on application, not server) | `100` |
### Debugging
| Variable | Description |
|----------|-------------|
| `WIVRN_DUMP_VIDEO` | Path to dump video frames (e.g., `/tmp/video-dump`) |
| `WIVRN_DUMP_TIMINGS` | Path to dump timing CSV (e.g., `/tmp/wivrn-timings.csv`) |
| `WIVRN_LOGLEVEL` | Log level for the native client |
| `WIVRN_AUTOCONNECT` | Auto-connect to the first discovered server |
| `XRT_TRACING` | Enable Perfetto tracing (`true`/`false`) |
### Vulkan
| Variable | Description |
|----------|-------------|
| `VK_INSTANCE_LAYERS` | Vulkan validation layers (e.g., `VK_LAYER_KHRONOS_validation`) |
### OpenXR
| Variable | Description |
|----------|-------------|
| `XR_RUNTIME_JSON` | Path to OpenXR runtime configuration |
See also the [Monado compositor documentation](https://monado.freedesktop.org/getting-started.html#compositor) for additional options.
---
## Configuration Files
### OpenXR Runtime Configuration
Active runtime symlink:
```bash
ls -la $HOME/.config/openxr/1/active_runtime.json
```
Should point to `/usr/share/openxr/1/openxr_wivrn.json` or similar.
Check runtime configuration:
```bash
cat /usr/share/openxr/1/openxr_wivrn.json
```
Example output:
```json
{
"file_format_version": "1.0.0",
"runtime": {
"name": "Monado",
"library_path": "../../../lib64/wivrn/libopenxr_wivrn.so",
"MND_libmonado_path": "../../../lib64/wivrn/libmonado_wivrn.so"
}
}
```
Verify library dependencies:
```bash
pushd /usr/share/openxr/1/
ldd ../../../lib64/wivrn/libopenxr_wivrn.so
popd
```
### WiVRn Server Configuration
See [docs/configuration.md](configuration.md).
---
## External Resources
### Tools and Documentation
- [ADB Documentation](https://developer.android.com/tools/adb) - Android Debug Bridge
- [ADB Logcat](https://developer.android.com/tools/logcat) - Log filtering and analysis
- [coredumpctl](https://www.freedesktop.org/software/systemd/man/latest/coredumpctl.html) - Core dump management
- [Perfetto](https://perfetto.dev/docs/) - System profiling and tracing
- [Perfetto UI](https://ui.perfetto.dev/) - Web-based trace viewer
### Monado/OpenXR
- [Monado Getting Started](https://monado.freedesktop.org/getting-started.html) - Compositor configuration
- [Monado Tracing with Perfetto](https://monado.pages.freedesktop.org/monado/tracing-perfetto.html) - Server-side tracing
- [OpenXR](https://www.khronos.org/openxr/) - Khronos OpenXR standard
- [xrgears](https://github.com/ila-embsys/monado_demo_xrgears) - OpenXR test application
### Gaming
- [OpenComposite](https://gitlab.com/znixian/OpenOVR) - OpenVR to OpenXR translation
- [xrizer](https://github.com/Supreeeme/xrizer) - OpenVR to OpenXR translation layer (Rust)
### Rust
- [env_logger](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) - Rust logging configuration via RUST_LOG
### Android Debugging
- [Android NDK Debugging](https://developer.android.com/ndk/guides/ndk-gdb) - Native debugging with ndk-gdb
- [Android Tracing Quickstart](https://perfetto.dev/docs/quickstart/android-tracing) - Perfetto on Android
---
## Remote Native Debugging (Advanced)
This section covers attaching a native debugger to the HMD client remotely. This requires the Android NDK and familiarity with LLDB/GDB.
Start the client with debugging enabled:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb shell am start -D ${WIVRN_PKG}/org.meumeu.wivrn.MainActivity
```
Set up LLDB debugging:
1. Push the LLDB server to the device:
```bash
adb shell "mkdir -p /data/local/tmp/tools"
adb push "$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux/aarch64/lldb-server" /data/local/tmp/tools/
```
2. Start the LLDB server on the device:
```bash
adb shell /data/local/tmp/tools/lldb-server platform --server --listen '*:5039'
```
3. Forward the port:
```bash
adb forward tcp:5039 tcp:5039
```
4. Connect from your host:
```bash
lldb
(lldb) platform select remote-android
(lldb) platform connect connect://localhost:5039
```
Resume the app (required for `-D` flag):
```bash
adb forward tcp:12345 jdwp:$(adb shell pidof ${WIVRN_PKG})
jdb -attach localhost:12345
```
See the [Android NDK debugging guide](https://developer.android.com/ndk/guides/ndk-gdb) for more details.
-17
View File
@@ -256,23 +256,6 @@ modules:
cleanup:
- '*'
- name: libnotify
buildsystem: meson
config-opts:
- -Dtests=false
- -Dintrospection=disabled
- -Dman=false
- -Dgtk_doc=false
- -Ddocbook_docs=disabled
sources:
- type: archive
url: https://download.gnome.org/sources/libnotify/0.8/libnotify-0.8.8.tar.xz
sha256: 23420ef619dc2cb5aebad613f4823a2fa41c07e5a1d05628d40f6ec4b35bfddd
x-checker-data:
type: gnome
name: libnotify
stable-only: true
- name: qcoro
buildsystem: cmake-ninja
config-opts:
+29 -10
View File
@@ -137,10 +137,6 @@ struct pipewire_device : public audio_device
// Declare target latency to help PipeWire optimize buffering
PW_KEY_NODE_LATENCY,
latency_str.c_str(),
// Force constant quantum size to prevent dynamic buffer size changes
// Variable buffer sizes cause crackling in effect processors (EasyEffects)
PW_KEY_NODE_FORCE_QUANTUM,
latency_str.c_str(),
NULL),
&speaker_events,
this));
@@ -154,6 +150,19 @@ struct pipewire_device : public audio_device
.channels = desc.speaker->num_channels,
};
switch (audio_info.channels)
{
case 1:
audio_info.position[0] = SPA_AUDIO_CHANNEL_MONO;
break;
case 2:
audio_info.position[0] = SPA_AUDIO_CHANNEL_FL;
audio_info.position[1] = SPA_AUDIO_CHANNEL_FR;
break;
default:
U_LOG_W("No known audio mapping for %d channels speaker", audio_info.channels);
}
const spa_pod * params[1];
params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &audio_info);
@@ -210,9 +219,6 @@ struct pipewire_device : public audio_device
// Declare target latency to help PipeWire optimize buffering
PW_KEY_NODE_LATENCY,
latency_str.c_str(),
// Force constant quantum size to prevent dynamic buffer size changes
PW_KEY_NODE_FORCE_QUANTUM,
latency_str.c_str(),
NULL),
&mic_events,
this));
@@ -225,6 +231,19 @@ struct pipewire_device : public audio_device
.channels = desc.microphone->num_channels,
};
switch (audio_info.channels)
{
case 1:
audio_info.position[0] = SPA_AUDIO_CHANNEL_MONO;
break;
case 2:
audio_info.position[0] = SPA_AUDIO_CHANNEL_FL;
audio_info.position[1] = SPA_AUDIO_CHANNEL_FR;
break;
default:
U_LOG_W("No known audio mapping for %d channels microphone", audio_info.channels);
}
const spa_pod * params[1];
params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &audio_info);
@@ -380,7 +399,7 @@ void pipewire_device::process_mic_data(wivrn::audio_data && sample)
mic_buffer_size_bytes += size;
}
std::shared_ptr<audio_device> create_pipewire_handle(
std::unique_ptr<audio_device> create_pipewire_handle(
const std::string & source_name,
const std::string & source_description,
const std::string & sink_name,
@@ -390,7 +409,7 @@ std::shared_ptr<audio_device> create_pipewire_handle(
{
try
{
return std::make_shared<pipewire_device>(
return std::make_unique<pipewire_device>(
source_name, source_description, sink_name, sink_description, info, session);
}
catch (std::exception & e)
@@ -399,4 +418,4 @@ std::shared_ptr<audio_device> create_pipewire_handle(
return nullptr;
}
}
} // namespace wivrn
} // namespace wivrn
+1 -1
View File
@@ -23,7 +23,7 @@
namespace wivrn
{
std::shared_ptr<audio_device> create_pipewire_handle(
std::unique_ptr<audio_device> create_pipewire_handle(
const std::string & source_name,
const std::string & source_description,
const std::string & sink_name,
+2 -2
View File
@@ -445,7 +445,7 @@ struct pulse_device : public audio_device
}
};
std::shared_ptr<audio_device> create_pulse_handle(
std::unique_ptr<audio_device> create_pulse_handle(
const std::string & source_name,
const std::string & source_description,
const std::string & sink_name,
@@ -455,7 +455,7 @@ std::shared_ptr<audio_device> create_pulse_handle(
{
try
{
return std::make_shared<pulse_device>(
return std::make_unique<pulse_device>(
source_name, source_description, sink_name, sink_description, info, session);
}
catch (std::exception & e)
+1 -1
View File
@@ -23,7 +23,7 @@
namespace wivrn
{
std::shared_ptr<audio_device> create_pulse_handle(
std::unique_ptr<audio_device> create_pulse_handle(
const std::string & source_name,
const std::string & source_description,
const std::string & sink_name,
+1 -1
View File
@@ -30,7 +30,7 @@
#include "audio_pipewire.h"
#endif
std::shared_ptr<wivrn::audio_device> wivrn::audio_device::create(
std::unique_ptr<wivrn::audio_device> wivrn::audio_device::create(
const std::string & source_name,
const std::string & source_description,
const std::string & sink_name,
+1 -1
View File
@@ -37,7 +37,7 @@ struct audio_device
virtual void process_mic_data(wivrn::audio_data &&) = 0;
static std::shared_ptr<audio_device> create(
static std::unique_ptr<audio_device> create(
const std::string & source_name,
const std::string & source_description,
const std::string & sink_name,
+1 -1
View File
@@ -137,7 +137,7 @@ class wivrn_session : public xrt_system_devices
std::mutex csv_mutex;
std::ofstream feedback_csv;
std::shared_ptr<audio_device> audio_handle;
std::unique_ptr<audio_device> audio_handle;
// run-time editable settings
thread_safe<from_headset::settings_changed> settings;
+31 -2
View File
@@ -328,7 +328,7 @@ std::array<encoder_settings, 3> get_encoder_settings(wivrn_vk_bundle & bundle, c
if (std::ranges::contains(res, video_codec::h264, &encoder_settings::codec) or
std::ranges::contains(res, video_codec::raw, &encoder_settings::codec))
bit_depth = 8;
else
else if (not bit_depth)
bit_depth = 10;
auto check_format = [&](vk::Format format) {
@@ -350,7 +350,36 @@ std::array<encoder_settings, 3> get_encoder_settings(wivrn_vk_bundle & bundle, c
}
};
if (bit_depth == 10 and not check_format(vk::Format::eR10X6UnormPack16))
auto check_vaapi = [&](int bit_depth) {
for (const auto & encoder: res)
{
if (encoder.encoder_name == encoder_vaapi)
{
try
{
video_encoder_va{
bundle,
encoder_settings{
.width = 800,
.height = 800,
.codec = encoder.codec,
.fps = 60,
.bitrate = 50'000'000,
.bit_depth = bit_depth,
},
0};
}
catch (std::exception & e)
{
U_LOG_I("vaapi not supported for %s %d bits", std::string(magic_enum::enum_name(encoder.codec)).c_str(), bit_depth);
return false;
}
}
}
return true;
};
if (bit_depth == 10 and not(check_format(vk::Format::eR10X6UnormPack16) and check_vaapi(*bit_depth)))
{
U_LOG_W("GPU does not have sufficient support for 10-bit images, reverting to 8");
bit_depth = 8;
+1 -1
View File
@@ -513,7 +513,7 @@ gboolean control_received(gint fd, GIOCondition condition, gpointer user_data)
[&](const wivrn::from_headset::start_app & request) {
const auto & apps = list_applications();
if (auto it = apps.find(request.app_id); it != apps.end())
children->start_application(it->second.exec);
children->start_application(it->second.exec, it->second.path);
},
[&](const from_monado::headset_connected &) {
stop_publishing();
+17 -3
View File
@@ -22,6 +22,7 @@
#include "utils/flatpak.h"
#include <cassert>
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
@@ -95,15 +96,15 @@ static std::vector<std::string> unescape_string(const std::string & app_string)
return app;
}
void children_manager::start_application(const std::string & exec)
void children_manager::start_application(const std::string & exec, const std::optional<std::string> & path)
{
start_application(unescape_string(exec));
start_application(unescape_string(exec), path);
}
forked_children::forked_children(std::function<void()> state_changed_cb) :
state_changed_cb(state_changed_cb) {}
void forked_children::start_application(const std::vector<std::string> & args)
void forked_children::start_application(const std::vector<std::string> & args, const std::optional<std::string> & path)
{
if (args.empty())
return;
@@ -151,6 +152,19 @@ void forked_children::start_application(const std::vector<std::string> & args)
{
tmp.push_back("flatpak-spawn");
tmp.push_back("--host");
if (path)
tmp.push_back("--directory=" + *path);
}
else
{
try
{
std::filesystem::current_path(*path);
}
catch (std::exception & e)
{
std::cerr << "Failed to set path to " << *path << ": " << e.what() << std::endl;
}
}
tmp.insert(tmp.end(), args.begin(), args.end());
+4 -3
View File
@@ -19,6 +19,7 @@
#include <functional>
#include <glib.h>
#include <optional>
#include <string>
#include <sys/types.h>
#include <unordered_map>
@@ -32,8 +33,8 @@ class children_manager
public:
virtual ~children_manager();
virtual void start_application(const std::vector<std::string> &) = 0;
void start_application(const std::string &);
virtual void start_application(const std::vector<std::string> &, const std::optional<std::string> & path = {}) = 0;
void start_application(const std::string &, const std::optional<std::string> & path = {});
virtual bool running() const = 0;
@@ -55,7 +56,7 @@ public:
forked_children(std::function<void()> state_changed_cb);
virtual ~forked_children();
void start_application(const std::vector<std::string> &) override;
void start_application(const std::vector<std::string> &, const std::optional<std::string> & path) override;
// true if any unit started by this object is still running
bool running() const override;
+12 -1
View File
@@ -196,11 +196,16 @@ struct variant_builder
}; // namespace
void systemd_units_manager::start_application(const std::vector<std::string> & args)
void systemd_units_manager::start_application(const std::vector<std::string> & args, const std::optional<std::string> & path)
{
if (args.empty())
return;
std::cerr << "Launching";
for (const auto & i: args)
std::cerr << " " << std::quoted(i);
std::cerr << std::endl;
std::string service_name = std::format("wivrn-application-{}.service", std::chrono::steady_clock::now().time_since_epoch().count());
variant_builder b(G_VARIANT_TYPE("a(sv)"));
@@ -224,6 +229,12 @@ void systemd_units_manager::start_application(const std::vector<std::string> & a
&exec_start,
1));
if (path)
g_variant_builder_add(&b,
"(sv)",
"WorkingDirectory",
g_variant_new("s", path->c_str()));
if (auto path = std::getenv("PATH"))
{
variant_builder pathv(G_VARIANT_TYPE("as"));
+1 -1
View File
@@ -54,7 +54,7 @@ public:
systemd_units_manager(GDBusConnection * connection, std::function<void()> state_changed_cb);
// create and start the transient unit
void start_application(const std::vector<std::string> &) override;
void start_application(const std::vector<std::string> &, const std::optional<std::string> & path) override;
// true if any unit started by this object is still running
bool running() const override;
+4 -1
View File
@@ -52,7 +52,10 @@ def main():
if args.nightly:
version = subprocess.check_output(["git", "describe", "--tags", "--always"]).decode().strip()
version = version[1:] # remove the initial "v"
if version[0] == 'v':
version = version[1:] # remove the initial "v"
else:
version = '0-' + version
write_entry(
out=args.out,
version=version,