Compare commits

..
Author SHA1 Message Date
xlulx 6dc3d01674 fix(display): apply a client's commit only after its GPU has finished writing the buffer (#3004) 2026-11-30 04:23:04 -05:00
MaxsTechReview df2cfa40b3 test(xbox): cover device-limit diagnostic routing (#3458) 2026-11-30 01:38:08 -05:00
MaxsTechReview e101a78791 fix(stores): the front end no longer crashes on start when the Steam engine starts on the refresh thread (#3457)
Keep the Steam install picker state out of the Steam engine object

The picker state lived on SteamStore, which is first touched from the
background stores refresh thread. On the Compose runtime in use, a state
object created outside a snapshot while the composition holds an open
snapshot is unreadable inside it, so the front end crashed on startup
with "Reading a state that was created after the snapshot was taken".
The state now lives on StoresState next to the other UI-facing store
state, and SteamStore holds no Compose state.
2026-11-30 00:02:07 -05:00
The412Banner aaa9fb129c fix(nativeguest): programs on a mount kept at its host path start as guest programs (#3211) 2026-11-29 23:58:32 -05:00
MaxsTechReview 23d7e639ca fix(steam): mark ARM64-uninstallable tool dependencies installed (#3443)
* fix(steam): mark ARM64-uninstallable tool dependencies installed

The ARM64 client cannot install Proton EasyAntiCheat Runtime (1826330),
which it refuses as an invalid platform, or that tool's Steam Linux
Runtime 1.0 (scout) dependency (1070560), which has no ARM64 depot. After
the EULA hand-off the client starts the dependency install and aborts in
glibc's smallbin check.

Write the bare installed manifest DroidDeck already uses for adopted games
for those two tools before the client starts: only on the ARM64 client,
only when appinfo shows no ARM64 depot, and never over a fully installed
manifest.

Refs: ValveSoftware/steam-for-linux#13937, DroidDeck #2313

* fix(steam): seed a tool only when no library has it installed, and write manifests atomically

A partial manifest in the first library no longer hides a full install in
another one, and a failed write leaves no truncated or stray manifest.

* fix(steam): publish tool manifests without replacing concurrent installs
2026-11-29 23:38:39 -05:00
MaxsTechReview 4ef23ed0e9 Return to the DroidDeck UI when logging out of the desktop (#3374)
* fix(desktop): Log Out returns to DroidDeck, Return to Gaming Mode opens Steam

Both ended Plasma through the same logout call and the desktop script always
started Steam afterwards. Return to Gaming Mode now leaves a request that the
script reads; a plain Log Out ends the desktop. The app ships the shortcut
with the script so both always change together.

* Wait for the logout reply so a cold Shutdown service still gets the request

* Forget the return to gaming mode when the logout request fails
2026-11-29 23:04:31 -05:00
ff35cce127 fix(steam): GTA III on Steam starts a new game (full x87 precision for app 12100) (#3197)
The Steam copy (AppID 12100) died on "Start new game" at 0042A703: FEX's reduced x87 precision turns a float into a bad pointer. GameEnvironment.knownGames sets FEX_X87REDUCEDPRECISION=0 for it, above the shared settings and below the game's own, and picking a FEX preset for the game keeps the fix.

Co-authored-by: Unixcision <14082251+Unixcision@users.noreply.github.com>
Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-29 22:51:35 -05:00
Tamim KabirandKurt Himebauch 0951b602b7 fix(input): programs built with _FORTIFY_SOURCE read the virtual pads (#2916)
* fix(input): programs built with _FORTIFY_SOURCE read the virtual pads

Fortified builds, Flatpak runtimes among them, call __read_chk, __poll_chk
and __ppoll_chk in place of read, poll and ppoll, and glibc's versions go
straight to the kernel. Such programs opened a pad through the shim but read
its backing ring file instead of events, so they never saw input: Marathon
Recompiled's SDL reads the pad through __read_chk.

The shim now provides all three, with glibc's bounds checks, on the same
paths as read, poll and ppoll.

* fix(input): keep glibc's __read_chk for descriptors that are not pads

Only pad descriptors take the shim's read path; the rest go to the next
__read_chk, so fortified reads keep libc's cancellation point. The test
also polls the empty ring with a zero timeout, which a __poll_chk that
bypasses the shim would report as ready.

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-29 22:51:30 -05:00
LarzVaderandKurt Himebauch 57055be6fb fix(ci): Robolectric's jar cache is saved again, and a Maven 429 runs the unit tests again (#3418)
* fix(ci): Robolectric's jar cache is saved again, and a Maven 429 runs the unit tests again

* fix(ci): retry Gradle artifact download rate limits too

* fix(ci): restrict Maven retry to dependency download exceptions

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-29 21:13:54 -05:00
68 changed files with 1210 additions and 251 deletions

No files matched your search

+17 -5
View File
@@ -740,7 +740,8 @@ jobs:
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
# The cache path sits beside the workspace because runner homes are at different depths from it, and
# actions/cache stores paths relative to the workspace. Runners that keep their own ~/.m2 skip the cache.
# actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects
# "..". Runners that keep their own ~/.m2 skip the cache.
- name: Place Robolectric's Android jars beside the workspace
id: robolectric-jars
run: |
@@ -751,7 +752,9 @@ jobs:
echo "cache=false" >> "$GITHUB_OUTPUT"
else
mkdir -p "$jars" "$(dirname "$m2")"
ln -sfn "$(cd "$jars" && pwd)" "$m2"
jars=$(cd "$jars" && pwd)
ln -sfn "$jars" "$m2"
echo "path=$jars" >> "$GITHUB_OUTPUT"
echo "cache=true" >> "$GITHUB_OUTPUT"
fi
- name: Restore Robolectric's Android jars
@@ -759,7 +762,7 @@ jobs:
if: steps.robolectric-jars.outputs.cache == 'true'
uses: actions/cache/restore@v4
with:
path: ../robolectric-jars
path: ${{ steps.robolectric-jars.outputs.path }}
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
- name: Count the restored Robolectric jars
@@ -773,7 +776,16 @@ jobs:
run: |
set -o pipefail
mkdir -p app/build
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log
# A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next.
for wait in 60 180 0; do
status=0
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log || status=$?
if [ "$status" = 0 ] || [ "$wait" = 0 ] || ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://repo\.maven\.apache\.org/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://repo\.maven\.apache\.org/)' app/build/unit-tests.log; then
exit "$status"
fi
echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s"
sleep "$wait"
done
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
@@ -800,7 +812,7 @@ jobs:
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
uses: actions/cache/save@v4
with:
path: ../robolectric-jars
path: ${{ steps.robolectric-jars.outputs.path }}
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
- name: Upload unit test diagnostics
+22
View File
@@ -4130,6 +4130,17 @@ EXPORT ssize_t read(int fd, void *buf, size_t count) {
return read_input(fd, buf, count);
}
extern "C" [[noreturn]] void __chk_fail(void);
/* Programs built with _FORTIFY_SOURCE (Flatpak runtimes among them) call these instead of read, poll
* and ppoll, and glibc's versions go straight to the kernel. */
EXPORT ssize_t __read_chk(int fd, void *buf, size_t count, size_t buflen) {
static auto next_read_chk = reinterpret_cast<ssize_t (*)(int, void *, size_t, size_t)>(dlsym(RTLD_NEXT, "__read_chk"));
if (count > buflen) __chk_fail();
if (next_read_chk && !is_fake_input_fd(fd)) return next_read_chk(fd, buf, count, buflen);
return read_input(fd, buf, count);
}
EXPORT ssize_t readv(int fd, const struct iovec *iov, int iovcnt) {
if (!is_fake_input_fd(fd)) return syscall(SYS_readv, fd, iov, iovcnt);
if (iovcnt < 0 || iovcnt > IOV_MAX) {
@@ -4378,6 +4389,17 @@ EXPORT int ppoll(struct pollfd *fds, nfds_t nfds,
return my_ppoll(fds, nfds, timeout, sigmask);
}
EXPORT int __poll_chk(struct pollfd *fds, nfds_t nfds, int timeout, size_t fdslen) {
if (fdslen / sizeof(*fds) < nfds) __chk_fail();
return poll(fds, nfds, timeout);
}
EXPORT int __ppoll_chk(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
const sigset_t *sigmask, size_t fdslen) {
if (fdslen / sizeof(*fds) < nfds) __chk_fail();
return ppoll(fds, nfds, timeout, sigmask);
}
EXPORT int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout) {
const auto my_select = next_symbol<decltype(&::select)>(Next::select);
+286 -39
View File
@@ -242,6 +242,10 @@ struct surface {
enum surface_role role;
struct wl_resource *idle_buffer;
struct wl_listener idle_buffer_destroy;
struct surface_state *waiting;
struct wl_event_source *waiting_source, *waiting_timer;
int waiting_fd;
int64_t waiting_since_ns;
uint32_t *idle_px;
int idle_w, idle_h;
struct wl_resource *xdg_surface, *xdg_toplevel;
@@ -373,6 +377,8 @@ static struct {
unsigned copy_scenes;
unsigned releases, releases_held;
int64_t release_ns, release_max_ns;
unsigned commit_waits, commit_wait_limits;
int64_t commit_wait_ns, commit_wait_max_ns;
} g_perf;
static void schedule_render(void);
@@ -846,6 +852,55 @@ static void on_pending_buffer_destroyed(struct wl_listener *l, void *data) {
s->pending_buffer = NULL;
}
struct surface_state {
struct wl_resource *buffer;
struct wl_listener buffer_destroy;
int attach;
int src_set, dst_set, opaque_set;
float src[4];
int dst[2], opaque[4];
struct damage_list damage_buf, damage_local;
struct wl_list frames, feedback;
};
static void on_state_buffer_destroyed(struct wl_listener *l, void *data) {
struct surface_state *st = wl_container_of(l, st, buffer_destroy);
wl_list_remove(&st->buffer_destroy.link);
wl_list_init(&st->buffer_destroy.link);
st->buffer = NULL;
st->attach = 0;
}
static void surface_state_take(struct surface *s, struct surface_state *st) {
st->attach = s->pending_attach;
st->buffer = s->pending_buffer;
wl_list_init(&st->buffer_destroy.link);
if (st->buffer) {
wl_list_remove(&s->pending_buffer_destroy.link);
wl_list_init(&s->pending_buffer_destroy.link);
st->buffer_destroy.notify = on_state_buffer_destroyed;
wl_resource_add_destroy_listener(st->buffer, &st->buffer_destroy);
}
s->pending_buffer = NULL;
s->pending_attach = 0;
st->src_set = s->pending_src_set;
memcpy(st->src, s->pending_src, sizeof(st->src));
st->dst_set = s->pending_dst_set;
memcpy(st->dst, s->pending_dst, sizeof(st->dst));
st->opaque_set = s->pending_opaque_set;
memcpy(st->opaque, s->pending_opaque, sizeof(st->opaque));
s->pending_src_set = s->pending_dst_set = s->pending_opaque_set = 0;
st->damage_buf = s->pending_damage_buf;
st->damage_local = s->pending_damage_local;
s->pending_damage_buf.n = s->pending_damage_local.n = 0;
wl_list_init(&st->frames);
wl_list_insert_list(&st->frames, &s->pending_frames);
wl_list_init(&s->pending_frames);
wl_list_init(&st->feedback);
wl_list_insert_list(&st->feedback, &s->pending_feedback);
wl_list_init(&s->pending_feedback);
}
static void fire_frames(struct wl_list *frames) {
struct wl_resource *cb, *tmp;
uint32_t t;
@@ -1363,35 +1418,23 @@ static void surface_drop_idle(struct surface *s) {
if (buffer) send_buffer_release(buffer);
}
static void surface_commit(struct wl_client *c, struct wl_resource *r) {
struct surface *s = wl_resource_get_user_data(r);
static void surface_state_apply(struct surface *s, struct surface_state *st) {
struct surface *child;
if (s->xdg_toplevel && !s->toplevel_committed) {
s->toplevel_committed = 1;
send_toplevel_configure(s);
if (st->src_set) {
s->src_set = st->src[2] > 0;
memcpy(s->src, st->src, sizeof(s->src));
}
if (st->dst_set) {
s->dst_set = st->dst[0] > 0;
memcpy(s->dst, st->dst, sizeof(s->dst));
}
if (st->opaque_set) memcpy(s->opaque, st->opaque, sizeof(s->opaque));
if (s->pending_src_set) {
s->src_set = s->pending_src[2] > 0;
memcpy(s->src, s->pending_src, sizeof(s->src));
s->pending_src_set = 0;
}
if (s->pending_dst_set) {
s->dst_set = s->pending_dst[0] > 0;
memcpy(s->dst, s->pending_dst, sizeof(s->dst));
s->pending_dst_set = 0;
}
if (s->pending_opaque_set) {
memcpy(s->opaque, s->pending_opaque, sizeof(s->opaque));
s->pending_opaque_set = 0;
}
s->damage_buf = s->pending_damage_buf;
s->damage_local = s->pending_damage_local;
s->pending_damage_buf.n = s->pending_damage_local.n = 0;
if (s->pending_attach) {
struct wl_resource *buffer = s->pending_buffer;
s->damage_buf = st->damage_buf;
s->damage_local = st->damage_local;
if (st->attach) {
struct wl_resource *buffer = st->buffer;
struct dmabuf_buffer *db = get_dmabuf(buffer);
struct wl_shm_buffer *shm = buffer && !db ? wl_shm_buffer_get(buffer) : NULL;
uint8_t pixel[4];
@@ -1400,12 +1443,10 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
if (!buffer) g_pace.null_attaches++;
else if (!db) s->last_dmabuf = NULL;
if (buffer) {
wl_list_remove(&s->pending_buffer_destroy.link);
wl_list_init(&s->pending_buffer_destroy.link);
}
s->pending_buffer = NULL;
s->pending_attach = 0;
wl_list_remove(&st->buffer_destroy.link);
wl_list_init(&st->buffer_destroy.link);
st->buffer = NULL;
st->attach = 0;
surface_drop_idle(s);
buf_trace_attach(buffer);
@@ -1442,10 +1483,10 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
}
}
wl_list_insert_list(s->frames.prev, &s->pending_frames);
wl_list_init(&s->pending_frames);
wl_list_insert_list(s->feedback.prev, &s->pending_feedback);
wl_list_init(&s->pending_feedback);
wl_list_insert_list(s->frames.prev, &st->frames);
wl_list_init(&st->frames);
wl_list_insert_list(s->feedback.prev, &st->feedback);
wl_list_init(&st->feedback);
constraints_surface_commit(s);
droiddeck_color_commit(s->resource);
@@ -1455,6 +1496,186 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
}
schedule_render();
}
#define COMMIT_WAIT_LIMIT_MS 1000
static struct surface *g_zero_copy_shown, *g_unwaited;
static int state_unfinished_fd(const struct surface *s, const struct surface_state *st, int *unwaited) {
struct dmabuf_buffer *db = st->attach ? get_dmabuf(st->buffer) : NULL;
int fd = -1;
*unwaited = 0;
for (int i = 0; db && fd < 0 && i < db->n_planes; i++) {
if (db->fd[i] < 0) continue;
struct pollfd p = {.fd = db->fd[i], .events = POLLIN};
int r;
do { r = poll(&p, 1, 0); } while (r < 0 && errno == EINTR);
if (r == 0) fd = db->fd[i];
}
if (fd >= 0 && s == g_zero_copy_shown && ahb_swapchain_has_ahb(db)) {
*unwaited = 1;
return -1;
}
return fd;
}
static void settle_unwaited(void) {
struct surface *s = g_unwaited;
if (!s) return;
g_unwaited = NULL;
struct dmabuf_buffer *db = s->dmabuf_buf;
const int64_t deadline = now_ns() + 100000000LL;
for (int i = 0; db && i < db->n_planes; i++) {
if (db->fd[i] < 0) continue;
struct pollfd p = {.fd = db->fd[i], .events = POLLIN};
for (;;) {
const int64_t left = deadline - now_ns();
const int r = poll(&p, 1, left > 0 ? (int)((left + 999999) / 1000000) : 0);
if (r >= 0 || errno != EINTR || left <= 0) break;
}
}
}
static void surface_state_discard(struct surface_state *st) {
struct wl_resource *cb, *tmp;
wl_list_remove(&st->buffer_destroy.link);
wl_resource_for_each_safe(cb, tmp, &st->frames) wl_resource_destroy(cb);
feedback_discard_all(&st->feedback);
free(st);
}
static void surface_state_merge(struct surface_state *older, struct surface_state *newer) {
if (older->attach && !newer->attach) {
newer->attach = 1;
newer->buffer = older->buffer;
wl_list_remove(&older->buffer_destroy.link);
wl_list_init(&older->buffer_destroy.link);
if (newer->buffer) {
newer->buffer_destroy.notify = on_state_buffer_destroyed;
wl_resource_add_destroy_listener(newer->buffer, &newer->buffer_destroy);
}
wl_list_insert_list(&newer->feedback, &older->feedback);
wl_list_init(&older->feedback);
} else if (older->attach) {
if (older->buffer && older->buffer != newer->buffer) send_buffer_release(older->buffer);
g_pace.replaced += feedback_discard_all(&older->feedback);
}
if (older->src_set && !newer->src_set) {
newer->src_set = 1;
memcpy(newer->src, older->src, sizeof(newer->src));
}
if (older->dst_set && !newer->dst_set) {
newer->dst_set = 1;
memcpy(newer->dst, older->dst, sizeof(newer->dst));
}
if (older->opaque_set && !newer->opaque_set) {
newer->opaque_set = 1;
memcpy(newer->opaque, older->opaque, sizeof(newer->opaque));
}
for (int i = 0; i < older->damage_buf.n; i++)
note_damage(&newer->damage_buf, older->damage_buf.r[i][0], older->damage_buf.r[i][1],
older->damage_buf.r[i][2], older->damage_buf.r[i][3]);
for (int i = 0; i < older->damage_local.n; i++)
note_damage(&newer->damage_local, older->damage_local.r[i][0], older->damage_local.r[i][1],
older->damage_local.r[i][2], older->damage_local.r[i][3]);
wl_list_insert_list(&newer->frames, &older->frames);
wl_list_init(&older->frames);
surface_state_discard(older);
}
static void surface_wait_stop(struct surface *s) {
if (s->waiting_source) wl_event_source_remove(s->waiting_source);
if (s->waiting_timer) wl_event_source_remove(s->waiting_timer);
if (s->waiting_fd >= 0) close(s->waiting_fd);
s->waiting_source = s->waiting_timer = NULL;
s->waiting_fd = -1;
}
static void surface_wait_end(struct surface *s, int over_limit) {
struct surface_state *st = s->waiting;
if (!st) return;
surface_wait_stop(s);
s->waiting = NULL;
const int64_t waited = now_ns() - s->waiting_since_ns;
g_perf.commit_waits++;
g_perf.commit_wait_ns += waited;
if (waited > g_perf.commit_wait_max_ns) g_perf.commit_wait_max_ns = waited;
if (over_limit) g_perf.commit_wait_limits++;
if (st->attach && g_unwaited == s) g_unwaited = NULL;
surface_state_apply(s, st);
free(st);
}
static int on_commit_ready(int fd, uint32_t mask, void *data) {
surface_wait_end(data, 0);
return 0;
}
static int on_commit_wait_limit(void *data) {
static int said;
if (!said) {
said = 1;
droiddeck_log("compositor", "a client's GPU writes ran past %d ms; its frame is shown as it is", COMMIT_WAIT_LIMIT_MS);
}
surface_wait_end(data, 1);
return 0;
}
static int surface_wait_start(struct surface *s, int fd, int timeout_ms) {
struct wl_event_loop *loop = wl_display_get_event_loop(g_display);
s->waiting_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
if (s->waiting_fd >= 0) {
s->waiting_source = wl_event_loop_add_fd(loop, s->waiting_fd, WL_EVENT_READABLE, on_commit_ready, s);
s->waiting_timer = wl_event_loop_add_timer(loop, on_commit_wait_limit, s);
}
if (!s->waiting_source || !s->waiting_timer ||
wl_event_source_timer_update(s->waiting_timer, timeout_ms) != 0) {
surface_wait_stop(s);
return -1;
}
return 0;
}
static void surface_commit(struct wl_client *c, struct wl_resource *r) {
struct surface *s = wl_resource_get_user_data(r);
if (s->xdg_toplevel && !s->toplevel_committed) {
s->toplevel_committed = 1;
send_toplevel_configure(s);
}
struct surface_state *st = calloc(1, sizeof(*st));
if (!st) {
struct surface_state now;
surface_state_take(s, &now);
surface_state_apply(s, &now);
return;
}
surface_state_take(s, st);
const int was_waiting = s->waiting != NULL;
if (was_waiting) {
surface_wait_stop(s);
surface_state_merge(s->waiting, st);
s->waiting = NULL;
}
int unwaited;
const int fd = state_unfinished_fd(s, st, &unwaited);
if (!was_waiting) s->waiting_since_ns = now_ns();
const int64_t left_ms = COMMIT_WAIT_LIMIT_MS - (now_ns() - s->waiting_since_ns) / 1000000;
if (fd >= 0 && left_ms > 0 && surface_wait_start(s, fd, (int)left_ms) == 0) {
s->waiting = st;
return;
}
const int attaches = st->attach;
if (was_waiting) {
s->waiting = st;
surface_wait_end(s, fd >= 0 && left_ms <= 0);
} else {
surface_state_apply(s, st);
free(st);
}
if (unwaited) g_unwaited = s;
else if (attaches && g_unwaited == s) g_unwaited = NULL;
}
static void surface_set_buffer_transform(struct wl_client *c, struct wl_resource *r, int32_t t) {}
static void surface_set_buffer_scale(struct wl_client *c, struct wl_resource *r, int32_t s) {}
static void surface_damage_buffer(struct wl_client *c, struct wl_resource *r,
@@ -1516,6 +1737,13 @@ static void surface_resource_destroy(struct wl_resource *r) {
child->parent = NULL;
}
if (s->pending_buffer) wl_list_remove(&s->pending_buffer_destroy.link);
if (s->waiting) {
surface_wait_stop(s);
surface_state_discard(s->waiting);
s->waiting = NULL;
}
if (g_zero_copy_shown == s) g_zero_copy_shown = NULL;
if (g_unwaited == s) g_unwaited = NULL;
pending_releases_forget_surface(s);
drop_dmabuf(s, 0);
ahb_swapchain_surface_gone(s);
@@ -1579,6 +1807,7 @@ static void compositor_create_surface(struct wl_client *c, struct wl_resource *r
wl_list_init(&s->child_link);
wl_list_init(&s->toplevel_link);
wl_list_init(&s->pending_buffer_destroy.link);
s->waiting_fd = -1;
wl_list_init(&s->idle_buffer_destroy.link);
wl_list_insert(&g_surfaces, &s->link);
wl_resource_set_implementation(s->resource, &surface_impl, s, surface_resource_destroy);
@@ -2502,7 +2731,13 @@ static int64_t scene_next_due(int64_t now, int64_t due, int limit) {
static void render_scene(void) {
g_scene_due_ns = scene_next_due(now_ns(), g_scene_due_ns, g_fps_limit);
if (atomic_load(&g_stream_on)) { g_dirty_since_ns = 0; render_stream(); return; }
if (atomic_load(&g_stream_on)) {
g_dirty_since_ns = 0;
g_zero_copy_shown = NULL;
settle_unwaited();
render_stream();
return;
}
struct draw_list dl = {0};
struct surface *s;
int w, h;
@@ -2576,6 +2811,8 @@ static void render_scene(void) {
} else {
cursor_hdr_said = 0;
}
g_zero_copy_shown = NULL;
if (hdr_route == 1 || hdr_route == 2) settle_unwaited();
if (hdr_route == 1) {
static int fell_back;
vkp_apply_window_request();
@@ -2609,6 +2846,7 @@ static void render_scene(void) {
}
if (hdr_route == 0 && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on &&
!ahb_only) {
settle_unwaited();
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
} else if (hdr_route == 0 || hdr_route == 3) {
const int pass_on = fx_on || framegen;
@@ -2658,6 +2896,7 @@ static void render_scene(void) {
vkp_apply_window_request();
int r = -1;
const int fg_pass = framegen && fx_on && li >= 0;
if (framegen && li >= 0) settle_unwaited();
const int generated = (framegen && li >= 0)
? sc_layer_present_generated(&dl.d[li], 1, NULL, w, h, fg_pass,
ls ? droiddeck_surface_color(ls) : NULL) : 0;
@@ -2671,6 +2910,8 @@ static void render_scene(void) {
r = generated >= 0 ? 0 : -1;
else if (generated >= 0 && !(fx_on && li >= 0) && ls && ls->dmabuf_buf && ahb_swapchain_has_ahb(ls->dmabuf_buf))
r = ahb_swapchain_present(ls->dmabuf_buf, ls, w, h, ld);
if (r == 0 && !fg_pass) g_zero_copy_shown = ls;
else settle_unwaited();
if (!fg_pass && generated >= 0 && r != 0 && li >= 0)
r = fx_on ? sc_layer_present_pass(&dl.d[li], 1, w, h)
: sc_layer_present(dl.d[li].img, w, h, ld, ls ? droiddeck_surface_color(ls) : NULL);
@@ -2681,6 +2922,7 @@ static void render_scene(void) {
ov = sc_layer_present_overlay(dl.d[li + 1].img, go, dl.d[li + 1].blend) == 0 ? 1 : -1;
if (ov <= 0) sc_layer_hide_overlay();
if (ov < 0) {
settle_unwaited();
sc_layer_hide();
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
copy = 1;
@@ -2690,12 +2932,14 @@ static void render_scene(void) {
g_scene_queues = sc_layer_queues();
}
} else {
settle_unwaited();
sc_layer_hide();
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
copy = 1;
hdr_copy = "its display layer was unavailable this frame";
}
} else {
settle_unwaited();
sc_layer_hide();
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
copy = 1;
@@ -4344,11 +4588,12 @@ static int on_stats_timer(void *data) {
unsigned aimed_next, aimed_later, aimed_even;
sc_layer_aim_take(&aimed_next, &aimed_later, &aimed_even);
#define PERF_MS(sum, n) ((n) ? (double)(sum) / 1e6 / (double)(n) : 0.0)
if (g_perf.scenes || vp.presents || g_perf.releases || drops)
if (g_perf.scenes || vp.presents || g_perf.releases || drops || g_perf.commit_waits)
droiddeck_log("perf", "last 10 s: %u ticks, %u scenes, %u on screen (copy %u, zero-copy %u, layer copy %u) | "
"render_scene %.2f/%.2f ms | base %u black kept, %u presented | acquire %.2f/%.2f ms | "
"present %.2f/%.2f ms (%u) | fence wait %.2f/%.2f ms (%u, %u GPU release waits) | "
"release %.2f/%.2f ms (%u, %u held) | %u pool drops | layer frames timed for the next refresh %u, "
"release %.2f/%.2f ms (%u, %u held) | commits held for client writes %.2f/%.2f ms (%u, %u past the limit) | "
"%u pool drops | layer frames timed for the next refresh %u, "
"the one after %u, held to an even step %u",
g_perf.ticks, g_perf.scenes, g_stat_frames, g_perf.copy_scenes, zero_copy, layer_frames,
PERF_MS(g_perf.scene_ns, g_perf.scenes), (double)g_perf.scene_max_ns / 1e6,
@@ -4357,7 +4602,9 @@ static int on_stats_timer(void *data) {
PERF_MS(vp.present_ns, vp.presents), (double)vp.present_max_ns / 1e6, vp.presents,
PERF_MS(vp.wait_ns, vp.waits), (double)vp.wait_max_ns / 1e6, vp.waits, vp.gpu_release_waits,
PERF_MS(g_perf.release_ns, g_perf.releases), (double)g_perf.release_max_ns / 1e6,
g_perf.releases, g_perf.releases_held, drops, aimed_next, aimed_later, aimed_even);
g_perf.releases, g_perf.releases_held,
PERF_MS(g_perf.commit_wait_ns, g_perf.commit_waits), (double)g_perf.commit_wait_max_ns / 1e6,
g_perf.commit_waits, g_perf.commit_wait_limits, drops, aimed_next, aimed_later, aimed_even);
#undef PERF_MS
memset(&g_perf, 0, sizeof(g_perf));
}
@@ -1038,18 +1038,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
onHandled()
return
}
val files = game.gameFiles?.takeIf { game.source == com.droiddeck.launcher.stores.Store.XBOX.id }
val steamClient = Library.fromSteamClient(game)
if (files == null && !steamClient) {
val files = game.gameFiles
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
if (startGame(game, returnHome, onHandled, request)) onSettled()
else launchCoordinator.releaseHandling(request)
return
}
val app = applicationContext
Thread({
val refused = files != null && com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
val uncached = steamClient && !com.droiddeck.launcher.session.NoSteamLaunch.enabled(app, game) &&
com.droiddeck.launcher.session.OfflineMode.lacksAppInfo(app, game.appId)
val refused = com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
ui.post {
when {
!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed -> {
@@ -1061,14 +1057,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
android.widget.Toast.makeText(this, getString(R.string.game_needs_app_model, game.name), android.widget.Toast.LENGTH_LONG).show()
onSettled()
}
else -> {
if (uncached) android.widget.Toast.makeText(this, getString(R.string.game_steam_offline_uncached, game.name), android.widget.Toast.LENGTH_LONG).show()
if (startGame(game, returnHome, onHandled, request)) onSettled()
else launchCoordinator.releaseHandling(request)
}
startGame(game, returnHome, onHandled, request) -> onSettled()
else -> launchCoordinator.releaseHandling(request)
}
}
}, "game-launch-check").start()
}, "xbox-app-model").start()
}
private fun startGame(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit, ticket: LaunchTicket): Boolean {
@@ -61,7 +61,19 @@ object GameEnvironment {
}
fun effective(config: Config, preset: String, scope: String, forceSsbs: Boolean = false): Map<String, String?> =
defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else config.games[scope].orEmpty()
defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else knownGames[scope].orEmpty() + config.games[scope].orEmpty()
/**
* What some Steam games need here whatever the shared settings say; the game's own settings still win.
* GTA III dies at 0042A703 when a new game starts with FEX's reduced x87 precision, as the Rockstar store copy does.
*/
val knownGames: Map<String, Map<String, String?>> = mapOf(
"12100" to mapOf("FEX_X87REDUCEDPRECISION" to "0"),
)
/** [config] with [knownGames] folded under each game's own settings, for the guest to read. */
fun withKnownGames(config: Config): Config =
config.copy(games = config.games + knownGames.mapValues { (scope, known) -> known + config.games[scope].orEmpty() })
fun hasOverride(config: Config, scope: String, name: String): Boolean =
scope.isNotEmpty() && config.entries(scope).containsKey(name)
@@ -78,7 +90,7 @@ object GameEnvironment {
val entries = config.games[scope].orEmpty()
if (FexPreset.environmentKeys.none(entries::containsKey)) return null
return FexPreset.all.firstOrNull { preset ->
val expected = FexPreset.environment(preset.id)
val expected = presetFor(scope, preset.id)
FexPreset.environmentKeys.all { key -> entries.containsKey(key) && entries[key] == expected[key] }
}?.id ?: CUSTOM_FEX_PRESET
}
@@ -88,12 +100,16 @@ object GameEnvironment {
require(preset == null || FexPreset.all.any { it.id == preset })
val entries = config.entries(scope).filterKeys { it !in FexPreset.environmentKeys }.toMutableMap()
if (preset != null) {
val values = FexPreset.environment(preset)
val values = presetFor(scope, preset)
FexPreset.environmentKeys.forEach { key -> entries[key] = values[key] }
}
return config.withEntries(scope, entries)
}
/** A FEX preset as a game gets it: picking one never undoes a fix the game is known to need. */
private fun presetFor(scope: String, preset: String): Map<String, String?> =
FexPreset.environment(preset) + knownGames[scope].orEmpty().filterKeys { it in FexPreset.environmentKeys }
const val CUSTOM_FEX_PRESET = "__custom__"
val syncBackends = listOf(SessionPrefs.SYNC_NTSYNC, SessionPrefs.SYNC_FSYNC, SessionPrefs.SYNC_ESYNC, SessionPrefs.SYNC_WINESERVER)
@@ -80,38 +80,20 @@ object SteamAppInfo {
private fun JSONArray?.strings(): List<String> = if (this == null) emptyList() else (0 until length()).map { optString(it) }
internal fun read(file: File, appId: Int): Info? = scan(file, appId, unreadable = null, missing = null) { raf, entry ->
if (entry.size > 64L * 1024 * 1024) return@scan null
val body = ByteArray(entry.size.toInt())
raf.readFully(body)
val strings = entry.tableAt?.let { readStrings(raf, it) }
val kv = ByteBuffer.wrap(body, entry.fixed, body.size - entry.fixed).order(ByteOrder.LITTLE_ENDIAN)
val tree = readMap(kv, strings)
@Suppress("UNCHECKED_CAST")
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
infoOf(app)
}
fun cached(file: File, appId: Int): Boolean? =
runCatching { scan(file, appId, unreadable = null, missing = false) { _, _ -> true } }
.onFailure { Log.w(TAG, "appinfo: ${it.javaClass.simpleName}") }
.getOrNull()
private class Entry(val fixed: Int, val tableAt: Long?, val size: Long)
private fun <T> scan(file: File, appId: Int, unreadable: T, missing: T, found: (RandomAccessFile, Entry) -> T): T {
if (!file.isFile) return unreadable
internal fun read(file: File, appId: Int): Info? {
if (!file.isFile) return null
RandomAccessFile(file, "r").use { raf ->
val head = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN)
raf.readFully(head.array(), 0, 8)
val magic = head.getInt(0)
val version = magic and 0xFF
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return unreadable
var tableAt: Long? = null
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return null
var strings: List<String>? = null
var pos = 8L
if (version >= 0x29) {
raf.readFully(head.array(), 8, 8)
tableAt = head.getLong(8)
val tableAt = head.getLong(8)
strings = readStrings(raf, tableAt)
pos = 16L
}
val fixed = if (version >= 0x28) 4 + 4 + 8 + 20 + 4 + 20 else 4 + 4 + 8 + 20 + 4
@@ -121,11 +103,20 @@ object SteamAppInfo {
raf.readFully(entry.array(), 0, 8)
val id = entry.getInt(0)
val size = entry.getInt(4).toLong() and 0xFFFFFFFFL
if (id == 0) return missing
if (id == appId) return found(raf, Entry(fixed, tableAt, size))
if (id == 0) return null
if (id == appId) {
if (size > 64L * 1024 * 1024) return null
val body = ByteArray(size.toInt())
raf.readFully(body)
val kv = ByteBuffer.wrap(body, fixed, body.size - fixed).order(ByteOrder.LITTLE_ENDIAN)
val tree = readMap(kv, strings)
@Suppress("UNCHECKED_CAST")
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
return infoOf(app)
}
pos += 8 + size
}
return missing
return null
}
}
@@ -114,7 +114,7 @@ object GameEnvironmentStore {
) {
publishGameCores(context)
val stored = config ?: read(context)
val resolved = stored.copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + stored.shared)
val resolved = GameEnvironment.withKnownGames(stored).copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + stored.shared)
val json = encode(resolved)
val dxvk = TextureFiltering.dxvkOptions(
SessionPrefs.textureAnisotropy(context), SessionPrefs.textureLodBias(context),
@@ -3,7 +3,6 @@ package com.droiddeck.launcher.session
import android.content.Context
import android.util.Log
import com.droiddeck.launcher.agent.AgentGuest
import com.droiddeck.launcher.frontend.SteamAppInfo
import com.droiddeck.launcher.runtime.LinuxRuntime
import java.io.File
@@ -64,9 +63,6 @@ object OfflineMode {
fun active(context: Context): Boolean =
offline(enabled(context), isOnline(context), auto(context))
fun lacksAppInfo(context: Context, appId: Int): Boolean =
active(context) && SteamAppInfo.cached(SteamAppInfo.appinfoFile(context), appId) == false
@Synchronized
fun setEnabled(context: Context, on: Boolean) {
write(context, LinuxRuntime.rootDir(context), on)
@@ -35,6 +35,7 @@ object SessionFiles {
"usr/local/bin/kwin_wayland_wrapper" to "usr/local/bin/kwin_wayland_wrapper",
"usr/lib/firefox/defaults/pref/droiddeck.js" to "usr/lib/firefox/defaults/pref/droiddeck.js",
"etc/xdg/autostart/droiddeck-clipboard.desktop" to "etc/xdg/autostart/droiddeck-clipboard.desktop",
"usr/share/applications/droiddeck-return-gaming.desktop" to "usr/share/applications/droiddeck-return-gaming.desktop",
"etc/xdg/fastfetch/config.jsonc" to "etc/xdg/fastfetch/config.jsonc",
)
@@ -121,6 +121,8 @@ object StoresState {
var unfinished by mutableStateOf<List<StoreInstallRoot.Unfinished>>(emptyList())
internal set
var steamPicking by mutableStateOf<CatalogItem?>(null)
fun isUnfinished(item: CatalogItem): Boolean = unfinished.any {
it.store == item.store && (it.id == item.id || (it.id == null && it.folder.name == StoreInstallRoot.folderName(item.title, item.id)))
}
@@ -6,9 +6,6 @@ import android.net.Uri
import android.util.Log
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.R
import com.droiddeck.launcher.frontend.Library
import com.droiddeck.launcher.session.SessionService
@@ -46,8 +43,6 @@ internal object SteamStore {
/** InvalidPassword, AccessDenied, AccountNotFound, Revoked, Expired, AccountLogonDenied. */
private val REFUSALS = setOf(5, 15, 18, 26, 27, 63)
var picking by mutableStateOf<CatalogItem?>(null)
class Plan(val installDir: String, val downloadBytes: Long, val installBytes: Long, val buildId: String, val linuxBuild: Boolean) {
companion object {
fun of(json: JSONObject): Plan? {
@@ -222,7 +217,7 @@ internal object SteamStore {
toast(context, R.string.steam_store_close_steam)
return
}
picking = item
StoresState.steamPicking = item
}
fun install(context: Context, item: CatalogItem, target: SteamClient.Target) {
@@ -847,7 +847,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
com.droiddeck.launcher.stores.StoresState.pendingInstall?.let { item -> StoreTheme(item.store) { InstallWhere(item) } }
com.droiddeck.launcher.stores.StoresState.itchPicking?.let { item -> StoreTheme(item.store) { ItchBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.itchPicking = null } } }
com.droiddeck.launcher.stores.StoresState.gameJoltPicking?.let { item -> StoreTheme(item.store) { GameJoltBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.gameJoltPicking = null } } }
com.droiddeck.launcher.stores.steam.SteamStore.picking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.steam.SteamStore.picking = null } } }
com.droiddeck.launcher.stores.StoresState.steamPicking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.StoresState.steamPicking = null } } }
StepsLayer(screenAt)
UiZooSheet()
SessionDrawerPreview(s.secondScreenDisplays)
-1
View File
@@ -4310,5 +4310,4 @@
<string name="steam_store_linux_build">تثبّت هذه اللعبة إصدار Linux الخاص بها. ثبّتها من Steam.</string>
<string name="game_zoom_title">تكبير اللعبة</string>
<string name="game_zoom_hint">اضبط تكبير اللعبة من 100% إلى 300%</string>
<string name="game_steam_offline_uncached">Steam في وضع عدم الاتصال ولم يحمّل %1$s بعد. اتصل بالإنترنت في Steam مرة واحدة لتشغيلها.</string>
</resources>
@@ -4188,5 +4188,4 @@
<string name="steam_store_close_steam">Cierra Steam primero</string>
<string name="steam_store_session_wait">Pausa primero la descarga de Steam</string>
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y todavía no cargó %1$s. Conéctate en Steam una vez para jugarlo.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Тази игра инсталира версията си за Linux. Инсталирайте я от Steam.</string>
<string name="game_zoom_title">Мащабиране на играта</string>
<string name="game_zoom_hint">Регулирайте увеличението на играта от 100% до 300%</string>
<string name="game_steam_offline_uncached">Steam е в офлайн режим и още не е заредил %1$s. Свържете Steam онлайн веднъж, за да я играете.</string>
</resources>
-1
View File
@@ -4230,5 +4230,4 @@
<string name="steam_store_linux_build">Tato hra instaluje svou verzi pro Linux. Nainstalujte ji ze Steamu.</string>
<string name="game_zoom_title">Přiblížení hry</string>
<string name="game_zoom_hint">Nastavte zvětšení hry od 100 % do 300 %</string>
<string name="game_steam_offline_uncached">Steam je v režimu offline a %1$s ještě nenačetl. Jednou se ve Steamu připojte online, abyste ji mohli hrát.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Dette spil installerer sin Linux-version. Installer det fra Steam.</string>
<string name="game_zoom_title">Spilzoom</string>
<string name="game_zoom_hint">Juster spillets forstørrelse fra 100 % til 300 %</string>
<string name="game_steam_offline_uncached">Steam er i offlinetilstand og har ikke indlæst %1$s endnu. Gå online i Steam én gang for at spille det.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Dieses Spiel installiert seine Linux-Version. Installiere es über Steam.</string>
<string name="game_zoom_title">Spielzoom</string>
<string name="game_zoom_hint">Spielvergrößerung von 100 % bis 300 % anpassen</string>
<string name="game_steam_offline_uncached">Steam ist im Offlinemodus und hat %1$s noch nicht geladen. Gehe einmal in Steam online, um es zu spielen.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Αυτό το παιχνίδι εγκαθιστά την έκδοσή του για Linux. Εγκαταστήστε το από το Steam.</string>
<string name="game_zoom_title">Ζουμ παιχνιδιού</string>
<string name="game_zoom_hint">Ρυθμίστε τη μεγέθυνση του παιχνιδιού από 100% έως 300%</string>
<string name="game_steam_offline_uncached">Το Steam είναι σε λειτουργία εκτός σύνδεσης και δεν έχει φορτώσει ακόμη το %1$s. Συνδεθείτε μία φορά στο Steam για να το παίξετε.</string>
</resources>
-1
View File
@@ -4190,5 +4190,4 @@
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
<string name="game_zoom_title">Zoom del juego</string>
<string name="game_zoom_hint">Ajusta la ampliación del juego del 100 % al 300 %</string>
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y aún no ha cargado %1$s. Conéctate en Steam una vez para jugarlo.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Tämä peli asentaa Linux-versionsa. Asenna se Steamista.</string>
<string name="game_zoom_title">Pelin zoomaus</string>
<string name="game_zoom_hint">Säädä pelin suurennusta välillä 100–300 %</string>
<string name="game_steam_offline_uncached">Steam on offline-tilassa eikä ole vielä ladannut peliä %1$s. Siirry Steamissa kerran online-tilaan pelataksesi sitä.</string>
</resources>
-1
View File
@@ -4189,5 +4189,4 @@
<string name="steam_store_linux_build">Ce jeu installe sa version Linux. Installez-le depuis Steam.</string>
<string name="game_zoom_title">Zoom du jeu</string>
<string name="game_zoom_hint">Réglez le grossissement du jeu de 100 % à 300 %</string>
<string name="game_steam_offline_uncached">Steam est en mode hors ligne et n\'a pas encore chargé %1$s. Passez en ligne une fois dans Steam pour y jouer.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">यह गेम अपना Linux संस्करण इंस्टॉल करता है। इसे Steam से इंस्टॉल करें।</string>
<string name="game_zoom_title">गेम ज़ूम</string>
<string name="game_zoom_hint">गेम का ज़ूम 100% से 300% तक समायोजित करें</string>
<string name="game_steam_offline_uncached">Steam ऑफ़लाइन मोड में है और उसने अभी तक %1$s लोड नहीं किया है। इसे खेलने के लिए Steam में एक बार ऑनलाइन जाएँ।</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Ez a játék a Linux-verzióját telepíti. Telepítsd a Steamből.</string>
<string name="game_zoom_title">Játék nagyítása</string>
<string name="game_zoom_hint">A játék nagyításának beállítása 100% és 300% között</string>
<string name="game_steam_offline_uncached">A Steam offline módban van, és még nem töltötte be ezt: %1$s. A játékhoz egyszer lépj online módba a Steamben.</string>
</resources>
-1
View File
@@ -4120,5 +4120,4 @@
<string name="steam_store_linux_build">Game ini memasang versi Linux-nya. Pasang dari Steam.</string>
<string name="game_zoom_title">Zoom game</string>
<string name="game_zoom_hint">Sesuaikan pembesaran game dari 100% hingga 300%</string>
<string name="game_steam_offline_uncached">Steam dalam mode luring dan belum memuat %1$s. Hubungkan Steam secara daring sekali untuk memainkannya.</string>
</resources>
-1
View File
@@ -4189,5 +4189,4 @@
<string name="steam_store_linux_build">Questo gioco installa la sua versione Linux. Installalo da Steam.</string>
<string name="game_zoom_title">Zoom del gioco</string>
<string name="game_zoom_hint">Regola l\'ingrandimento del gioco dal 100% al 300%</string>
<string name="game_steam_offline_uncached">Steam è in modalità offline e non ha ancora caricato %1$s. Vai online in Steam una volta per giocarci.</string>
</resources>
-1
View File
@@ -4120,5 +4120,4 @@
<string name="steam_store_linux_build">このゲームは Linux 版をインストールします。Steam からインストールしてください。</string>
<string name="game_zoom_title">ゲームズーム</string>
<string name="game_zoom_hint">ゲームの拡大率を100%から300%の間で調整します</string>
<string name="game_steam_offline_uncached">Steam はオフラインモードのため、%1$s をまだ読み込んでいません。プレイするには Steam で一度オンラインにしてください。</string>
</resources>
-1
View File
@@ -4120,5 +4120,4 @@
<string name="steam_store_linux_build">이 게임은 Linux 버전을 설치합니다. Steam에서 설치하세요.</string>
<string name="game_zoom_title">게임 확대</string>
<string name="game_zoom_hint">게임 확대율을 100%에서 300%까지 조정합니다</string>
<string name="game_steam_offline_uncached">Steam이 오프라인 모드이며 아직 %1$s을(를) 불러오지 않았습니다. 플레이하려면 Steam에서 한 번 온라인으로 전환하세요.</string>
</resources>
-1
View File
@@ -4120,5 +4120,4 @@
<string name="steam_store_linux_build">Permainan ini memasang versi Linuxnya. Pasang daripada Steam.</string>
<string name="game_zoom_title">Zum permainan</string>
<string name="game_zoom_hint">Laraskan pembesaran permainan daripada 100% hingga 300%</string>
<string name="game_steam_offline_uncached">Steam dalam mod luar talian dan belum memuatkan %1$s. Pergi dalam talian dalam Steam sekali untuk memainkannya.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Dette spillet installerer Linux-versjonen sin. Installer det fra Steam.</string>
<string name="game_zoom_title">Spillzoom</string>
<string name="game_zoom_hint">Juster spillforstørrelsen fra 100 % til 300 %</string>
<string name="game_steam_offline_uncached">Steam er i frakoblet modus og har ikke lastet inn %1$s ennå. Gå tilkoblet i Steam én gang for å spille det.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Deze game installeert zijn Linux-versie. Installeer hem via Steam.</string>
<string name="game_zoom_title">Gamezoom</string>
<string name="game_zoom_hint">Pas de spelvergroting aan van 100% tot 300%</string>
<string name="game_steam_offline_uncached">Steam staat in offlinemodus en heeft %1$s nog niet geladen. Ga één keer online in Steam om het te spelen.</string>
</resources>
-1
View File
@@ -4230,5 +4230,4 @@
<string name="steam_store_linux_build">Ta gra instaluje swoją wersję dla Linuksa. Zainstaluj ją ze Steama.</string>
<string name="game_zoom_title">Powiększenie gry</string>
<string name="game_zoom_hint">Dostosuj powiększenie gry w zakresie od 100% do 300%</string>
<string name="game_steam_offline_uncached">Steam jest w trybie offline i nie wczytał jeszcze %1$s. Przejdź raz do trybu online w Steamie, aby w to zagrać.</string>
</resources>
@@ -4189,5 +4189,4 @@
<string name="steam_store_linux_build">Este jogo instala a sua versão para Linux. Instale-o a partir do Steam.</string>
<string name="game_zoom_title">Zoom do jogo</string>
<string name="game_zoom_hint">Ajuste a ampliação do jogo de 100% a 300%</string>
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
</resources>
-1
View File
@@ -4197,5 +4197,4 @@
<string name="steam_store_close_steam">Feche o Steam primeiro</string>
<string name="steam_store_session_wait">Pause o download do Steam primeiro</string>
<string name="steam_store_linux_build">Este jogo instala sua versão para Linux. Instale-o pelo Steam.</string>
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
</resources>
-1
View File
@@ -4190,5 +4190,4 @@
<string name="steam_store_linux_build">Acest joc își instalează versiunea pentru Linux. Instalează-l din Steam.</string>
<string name="game_zoom_title">Zoom joc</string>
<string name="game_zoom_hint">Reglați mărirea jocului între 100% și 300%</string>
<string name="game_steam_offline_uncached">Steam este în modul offline și nu a încărcat încă %1$s. Treci o dată online în Steam ca să îl joci.</string>
</resources>
-1
View File
@@ -4231,5 +4231,4 @@
<string name="steam_store_linux_build">Эта игра устанавливает свою версию для Linux. Установите её из Steam.</string>
<string name="game_zoom_title">Масштаб игры</string>
<string name="game_zoom_hint">Настройте увеличение игры от 100% до 300%</string>
<string name="game_steam_offline_uncached">Steam в автономном режиме и ещё не загрузил %1$s. Чтобы играть, один раз переведите Steam в сеть.</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Det här spelet installerar sin Linux-version. Installera det från Steam.</string>
<string name="game_zoom_title">Spelzoom</string>
<string name="game_zoom_hint">Justera spelförstoringen från 100 % till 300 %</string>
<string name="game_steam_offline_uncached">Steam är i offlineläge och har inte läst in %1$s än. Gå online i Steam en gång för att spela det.</string>
</resources>
-1
View File
@@ -4120,5 +4120,4 @@
<string name="steam_store_linux_build">เกมนี้ติดตั้งเวอร์ชัน Linux ของตัวเอง ให้ติดตั้งจาก Steam</string>
<string name="game_zoom_title">ซูมเกม</string>
<string name="game_zoom_hint">ปรับการขยายเกมตั้งแต่ 100% ถึง 300%</string>
<string name="game_steam_offline_uncached">Steam อยู่ในโหมดออฟไลน์และยังไม่ได้โหลด %1$s ออนไลน์ใน Steam หนึ่งครั้งเพื่อเล่นเกมนี้</string>
</resources>
-1
View File
@@ -4150,5 +4150,4 @@
<string name="steam_store_linux_build">Bu oyun Linux sürümünü yükler. Steam\'den yükleyin.</string>
<string name="game_zoom_title">Oyun yakınlaştırma</string>
<string name="game_zoom_hint">Oyun yakınlaştırmasını %100 ile %300 arasında ayarlayın</string>
<string name="game_steam_offline_uncached">Steam çevrimdışı modda ve %1$s henüz yüklenmedi. Oynamak için Steam\'de bir kez çevrimiçi olun.</string>
</resources>
-1
View File
@@ -4230,5 +4230,4 @@
<string name="steam_store_linux_build">Ця гра встановлює свою версію для Linux. Установіть її зі Steam.</string>
<string name="game_zoom_title">Масштаб гри</string>
<string name="game_zoom_hint">Налаштуйте збільшення гри від 100% до 300%</string>
<string name="game_steam_offline_uncached">Steam в офлайн-режимі й ще не завантажив %1$s. Щоб грати, один раз перейдіть у Steam онлайн.</string>
</resources>
-1
View File
@@ -4120,5 +4120,4 @@
<string name="steam_store_linux_build">Trò chơi này cài bản dành cho Linux. Hãy cài từ Steam.</string>
<string name="game_zoom_title">Thu phóng trò chơi</string>
<string name="game_zoom_hint">Điều chỉnh độ phóng đại trò chơi từ 100% đến 300%</string>
<string name="game_steam_offline_uncached">Steam đang ở chế độ ngoại tuyến và chưa tải %1$s. Hãy trực tuyến trong Steam một lần để chơi.</string>
</resources>
@@ -4118,5 +4118,4 @@
<string name="steam_store_close_steam">请先关闭 Steam</string>
<string name="steam_store_session_wait">请先暂停 Steam 下载</string>
<string name="steam_store_linux_build">此游戏会安装其 Linux 版本。请通过 Steam 安装。</string>
<string name="game_steam_offline_uncached">Steam 处于离线模式,尚未加载 %1$s。请在 Steam 中联网一次后再玩。</string>
</resources>
@@ -4118,5 +4118,4 @@
<string name="steam_store_close_steam">請先關閉 Steam</string>
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
</resources>
@@ -4118,5 +4118,4 @@
<string name="steam_store_close_steam">請先關閉 Steam</string>
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
</resources>
-1
View File
@@ -1755,7 +1755,6 @@
<string name="game_link_session_busy">Stop the current session before launching a Steam game.</string>
<string name="game_link_failed">Could not send the game to Steam. Try launching it again.</string>
<string name="game_needs_app_model">%1$s is a UWP app. This runtime has no Windows app-model host to start it.</string>
<string name="game_steam_offline_uncached">Steam is in offline mode and has not loaded %1$s yet. Go online in Steam once to play it.</string>
<string name="setup_retry_removal">Retry removal</string>
<string name="runtime_removing">Removing</string>
<string name="runtime_removal_incomplete">Removal incomplete</string>
@@ -20,6 +20,24 @@ class GameEnvironmentTest {
assertEquals("1", GameEnvironment.effective(config, "", "43", forceSsbs = true)[GameEnvironment.FORCE_SSBS])
}
@Test fun knownGameFixesBeatSharedSettingsButNotTheGamesOwn() {
val shared = GameEnvironment.Config(shared = mapOf("FEX_X87REDUCEDPRECISION" to "1"))
assertEquals("0", GameEnvironment.effective(shared, "PERFORMANCE_TSO", "12100")["FEX_X87REDUCEDPRECISION"])
assertEquals("1", GameEnvironment.effective(shared, "PERFORMANCE_TSO", "12110")["FEX_X87REDUCEDPRECISION"])
val own = shared.withEntries("12100", mapOf("FEX_X87REDUCEDPRECISION" to "1"))
assertEquals("1", GameEnvironment.effective(own, "PERFORMANCE_TSO", "12100")["FEX_X87REDUCEDPRECISION"])
assertEquals("1", GameEnvironment.withKnownGames(own).games["12100"]?.get("FEX_X87REDUCEDPRECISION"))
assertEquals("0", GameEnvironment.withKnownGames(shared).games["12100"]?.get("FEX_X87REDUCEDPRECISION"))
}
@Test fun aGamePresetKeepsTheGamesKnownFix() {
val picked = GameEnvironment.withGameFexPreset(GameEnvironment.Config(), "12100", "PERFORMANCE")
assertEquals("0", GameEnvironment.effective(picked, "PERFORMANCE_TSO", "12100")["FEX_X87REDUCEDPRECISION"])
assertEquals("PERFORMANCE", GameEnvironment.gameFexPreset(picked, "12100"))
val other = GameEnvironment.withGameFexPreset(GameEnvironment.Config(), "12110", "PERFORMANCE")
assertEquals("1", GameEnvironment.effective(other, "PERFORMANCE_TSO", "12110")["FEX_X87REDUCEDPRECISION"])
}
@Test fun gameOverridesSharedAndPresetWithoutLeakingToOtherGames() {
val config = GameEnvironment.Config(
shared = mapOf("FEX_MULTIBLOCK" to "0", "VKD3D_FEATURE_LEVEL" to "12_2"),
@@ -1,64 +0,0 @@
package com.droiddeck.launcher.frontend
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.ByteBuffer
import java.nio.ByteOrder
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33])
class SteamAppInfoTest {
@get:Rule val tmp = TemporaryFolder()
private fun file() = File(tmp.newFolder(), "appinfo.vdf")
private fun le(size: Int) = ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN)
private fun writeV28(file: File, appId: Int, name: String) {
val kv = ByteArrayOutputStream().apply {
fun cstring(s: String) { write(s.toByteArray()); write(0) }
write(0x00); cstring("appinfo")
write(0x00); cstring("common")
write(0x01); cstring("name"); cstring(name)
write(0x08); write(0x08); write(0x08)
}.toByteArray()
val body = ByteArray(60) + kv
val out = le(8 + 8 + body.size + 4).putInt(0x07564428).putInt(1).putInt(appId).putInt(body.size).put(body).putInt(0)
file.writeBytes(out.array())
}
@Test fun anAppInTheClientsCacheIsToldApartFromOneMissingFromIt() {
val file = file()
WinCompSourcesTest.writeAppinfo(file, 17470)
assertEquals(true, SteamAppInfo.cached(file, 17470))
assertEquals(false, SteamAppInfo.cached(file, 1145360))
}
@Test fun theOlderFormatWithoutAStringTableIsReadToo() {
val file = file()
writeV28(file, 17470, "Some Game")
assertTrue(SteamAppInfo.cached(file, 17470)!!)
assertFalse(SteamAppInfo.cached(file, 22330)!!)
assertEquals("Some Game", SteamAppInfo.read(file, 17470)!!.name)
assertNull(SteamAppInfo.read(file, 22330))
}
@Test fun aMissingOrUnknownCacheIsNotTakenAsMissingTheApp() {
val missing = file()
assertNull(SteamAppInfo.cached(missing, 17470))
val newer = file().apply { writeBytes(le(16).putInt(0x0756442A).putInt(1).array()) }
assertNull(SteamAppInfo.cached(newer, 17470))
val garbage = file().apply { writeBytes(byteArrayOf(1, 2, 3)) }
assertNull(SteamAppInfo.cached(garbage, 17470))
}
}
@@ -202,11 +202,19 @@ class GameEnvironmentStoreTest {
assertEquals("false", published.shared["MESA_SHADER_CACHE_DISABLE"])
assertFalse(published.shared.containsKey("VKD3D_FEATURE_LEVEL"))
assertFalse(published.shared.containsKey("VKD3D_SHADER_MODEL"))
assertEquals(config.games, published.games)
assertEquals(config.games + GameEnvironment.knownGames, published.games)
assertEquals(config.shared["LITERAL"], published.shared["LITERAL"])
assertEquals("", published.shared["EMPTY"])
}
@Test fun aKnownGamesFixReachesTheGuestWithoutBeingSavedAsTheUsersSetting() {
GameEnvironmentStore.save(context, GameEnvironment.Config())
assertEquals(emptyMap<String, Map<String, String?>>(), GameEnvironmentStore.read(context).games)
val published = GameEnvironmentStore.decode(JSONObject(guest.readText()))
assertEquals(GameEnvironment.knownGames, published.games)
assertEquals("0", published.entries("12100")["FEX_X87REDUCEDPRECISION"])
}
@Test fun publishingPreservesExplicitSharedGraphicsCapabilities() {
val config = GameEnvironment.Config(shared = mapOf(
"VKD3D_FEATURE_LEVEL" to "12_1", "VKD3D_SHADER_MODEL" to "6_6",
@@ -266,7 +274,7 @@ class GameEnvironmentStoreTest {
assertEquals(original.entries("43"), saved.entries("43"))
assertEquals("PERFORMANCE_TSO", SessionPrefs.fexPreset(context))
val published = GameEnvironmentStore.decode(JSONObject(guest.readText()))
assertEquals(saved.games, published.games)
assertEquals(saved.games + GameEnvironment.knownGames, published.games)
assertEquals("0", published.shared["FEX_HALFBARRIERTSOENABLED"])
assertEquals("1", published.entries("42")["FEX_HALFBARRIERTSOENABLED"])
}
@@ -54,32 +54,6 @@ class OfflineModeTest {
shadowOf(cm).setNetworkCapabilities(cm.activeNetwork, caps)
}
private fun clientCache(appId: Int) =
com.droiddeck.launcher.frontend.WinCompSourcesTest.writeAppinfo(com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context), appId)
@Test
fun offlineSteamReportsAGameMissingFromItsCache() {
writeSteam("1")
clientCache(220)
assertTrue(OfflineMode.active(context))
assertTrue(OfflineMode.lacksAppInfo(context, 17470))
assertFalse(OfflineMode.lacksAppInfo(context, 220))
}
@Test
fun onlineSteamNeverReportsAMissingGame() {
clientCache(220)
assertFalse(OfflineMode.active(context))
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
}
@Test
fun offlineSteamWithoutAReadableCacheReportsNothing() {
writeSteam("1")
com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context).delete()
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
}
@Test
fun offlineWhenChosenOrWithoutInternet() {
assertFalse(OfflineMode.offline(manual = false, online = true))
@@ -0,0 +1,37 @@
package com.droiddeck.launcher.stores.steam
import androidx.compose.runtime.State
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.runtime.snapshots.StateObject
import com.droiddeck.launcher.stores.StoresState
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import kotlin.concurrent.thread
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33], manifest = Config.NONE)
class SteamPickingSnapshotTest {
@Test
fun theInstallPickerIsReadableInASnapshotOpenedBeforeTheSteamEngineStarts() {
StoresState.steamPicking = null
val snapshot = Snapshot.takeMutableSnapshot()
try {
thread { SteamStore.hashCode() }.join()
assertNull(snapshot.enter { StoresState.steamPicking })
} finally {
snapshot.dispose()
}
}
@Test
fun theSteamEngineHoldsNoComposeState() {
val stateFields = SteamStore::class.java.declaredFields.filter {
StateObject::class.java.isAssignableFrom(it.type) || State::class.java.isAssignableFrom(it.type)
}
assertTrue(stateFields.joinToString { it.name }, stateFields.isEmpty())
}
}
@@ -9,6 +9,25 @@ import org.junit.Test
class XodusDiagnosticsTest {
private val rejected = Regex(Xodus.SIGN_IN_REJECTED)
@Test fun aDeviceLimitReachesTheInstallerWithoutBecomingASignInFailure() {
val line = "NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200"
val tail = listOf(line).filter { it.matches(Xodus.reportable) }
assertEquals(listOf(line), tail)
assertFalse(line.matches(rejected))
assertEquals(com.droiddeck.launcher.R.string.stores_xbox_device_group_full, XboxInstaller.licenseRefusal(tail))
}
@Test fun aLaterLicenseSuccessClearsTheDeviceLimitThroughTheDiagnosticFilter() {
val stderr = listOf(
"NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200",
"NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-parsed 200",
"NEXUS_EXTRACT_DIAGNOSTIC_V1 extract-failed"
)
val tail = stderr.filter { it.matches(Xodus.reportable) }
assertEquals(stderr, tail)
assertNull(XboxInstaller.licenseRefusal(tail))
}
@Test fun aContentLicenseRejectionIsRecognised() {
assertTrue("Microsoft content licensing rejected sign-in (HTTP 401). Sign in again in Settings.".matches(rejected))
}
@@ -1,9 +0,0 @@
[Desktop Entry]
Name=Return to Gaming Mode
Comment=Log out of the desktop and go back to Steam
Exec=dbus-send --session --type=method_call --dest=org.kde.Shutdown /Shutdown org.kde.Shutdown.logout
Icon=steamdeck-gaming-return
Terminal=false
Type=Application
StartupNotify=false
NoDisplay=true
+5 -1
View File
@@ -229,12 +229,16 @@ fi
if ! /usr/local/bin/droiddeck-pipewire start; then
echo "== pipewire: not running; screen capture has no picture"
fi
return_gaming=/run/droiddeck/return-gaming
mkdir -p /run/droiddeck
rm -f "$return_gaming"
echo "== droiddeck-desktop: Plasma on $WAYLAND_DISPLAY"
dbus-run-session -- startplasma-wayland
rc=$?
/usr/local/bin/droiddeck-pipewire stop
echo "== droiddeck-desktop: Plasma ended ($rc)"
if [ "$rc" -eq 0 ] && [ -z "${DD_BOTTOM_DESKTOP:-}" ]; then
if [ "$rc" -eq 0 ] && [ -z "${DD_BOTTOM_DESKTOP:-}" ] && [ -e "$return_gaming" ]; then
rm -f "$return_gaming"
/usr/local/bin/droiddeck-steam-launch bigpicture
sleep 30
fi
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Return to Gaming Mode
Comment=Log out of the desktop and go back to Steam
Exec=sh -c ": > /run/droiddeck/return-gaming; dbus-send --session --print-reply --type=method_call --dest=org.kde.Shutdown /Shutdown org.kde.Shutdown.logout >/dev/null || rm -f /run/droiddeck/return-gaming"
Icon=steamdeck-gaming-return
Terminal=false
Type=Application
StartupNotify=false
NoDisplay=true
@@ -1149,6 +1149,7 @@ case $mode in
droiddeck-steam-library "$steam_root" || true
step "setting up the ARM64 Proton compatibility tool"
steam-compatibility "$steam_root" || true
steam-compatibility "$steam_root" --seed-arm64-tools || true
if [ -z "${DD_DESKTOP:-}" ] && [ "${DD_STEAM_UI:-}" != desktop ]; then
droiddeck-steam-ui-scale "$steam_root" "${DD_WIDTH:-1280}" "${DD_HEIGHT:-720}" || true
fi
@@ -5,6 +5,7 @@ import re
import runpy
import shutil
import sys
import tempfile
TOOL = "droiddeck-proton-arm64"
TOOL_11 = "droiddeck-proton-11-arm64"
@@ -26,6 +27,8 @@ SNIPER_APPID = "1628350"
SLR4_APPID = "4183110"
FEX_DEPENDENCIES = (FEX_APPID, SNIPER_APPID, SLR4_APPID)
REQUIRED_TOOLS = (PROTON_ARM64_APPID,) + FEX_DEPENDENCIES
ARM64_TOOL_DEPENDENCIES = (("1826330", "Proton EasyAntiCheat Runtime"),
("1070560", "Steam Linux Runtime 1.0 (scout)"))
# "0" = the app's "Valve Proton only when needed": Valve's ARM64 Proton is fetched only for a title or
# default set to a tool built from it, or while no own Proton build is installed.
VALVE_PROTON_ENV = "DD_VALVE_PROTON"
@@ -1012,10 +1015,15 @@ def manifest_text(appid, name, installdir, bare=False):
return text[:-2] + ' "AutoUpdateBehavior" "1"\n}\n' if bare else text
def app_manifest(steam_root, app):
def manifest_paths(steam_root, app):
for library in libraries(steam_root):
yield os.path.join(library, "steamapps", "appmanifest_%s.acf" % app)
def app_manifest(steam_root, app):
for path in manifest_paths(steam_root, app):
try:
with open(os.path.join(library, "steamapps", "appmanifest_%s.acf" % app), encoding="utf-8", errors="replace") as f:
with open(path, encoding="utf-8", errors="replace") as f:
return tokenize(f.read())
except OSError:
continue
@@ -1030,6 +1038,57 @@ def manifest_flags(tokens):
return 0
def installed_manifest(path):
try:
with open(path, encoding="utf-8", errors="replace") as f:
return bool(manifest_flags(tokenize(f.read())) & FULLY_INSTALLED)
except OSError:
return False
def seed_unavailable_arm64_tools(steam_root):
entries = appinfo_entries(os.path.join(steam_root, "appcache", "appinfo.vdf"),
[app for app, _ in ARM64_TOOL_DEPENDENCIES])
steamapps = os.path.join(steam_root, "steamapps")
os.makedirs(steamapps, exist_ok=True)
seeded = []
for app, display in ARM64_TOOL_DEPENDENCIES:
entry = entries.get(app)
if entry is not None:
if entry["type"] not in ("", "tool"):
continue
if "arm64" in entry["osarch"] or "aarch64" in entry["osarch"]:
continue
existing = [p for p in manifest_paths(steam_root, app) if os.path.isfile(p)]
if any(installed_manifest(p) for p in existing):
continue
name = (entry or {}).get("name") or display
installdir = (entry or {}).get("installdir") or name
path = existing[0] if existing else os.path.join(steamapps, "appmanifest_%s.acf" % app)
temporary = None
try:
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8",
dir=os.path.dirname(path),
prefix=".appmanifest_", delete=False) as f:
temporary = f.name
f.write(manifest_text(app, name, installdir, True))
if existing:
os.replace(temporary, path)
else:
os.link(temporary, path)
except OSError as e:
print("steam-compatibility: could not mark %s installed (%s)" % (app, e))
continue
finally:
if temporary is not None:
try:
os.unlink(temporary)
except OSError:
pass
seeded.append(app)
return seeded
def valve_proton_on_demand():
return os.environ.get(VALVE_PROTON_ENV) == "0"
@@ -1801,6 +1860,11 @@ def main():
steam_root = sys.argv[1]
if "--valve-proton-needed" in sys.argv[2:]:
sys.exit(0 if valve_proton_needed(steam_root) else 1)
if "--seed-arm64-tools" in sys.argv[2:]:
seeded = seed_unavailable_arm64_tools(steam_root)
if seeded:
print("steam-compatibility: marked unavailable ARM64 tool(s) installed: %s" % ", ".join(seeded))
return
if "--x64" in sys.argv[2:]:
x64_repoint(steam_root, os.environ.get("DD_COMPAT_TOOL"), "--live" in sys.argv[2:])
return
+4 -2
View File
@@ -452,7 +452,8 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
char resolved_target[PATH_MAX];
// Only intercept binaries/scripts within DDNATV_ROOT
if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename)) {
if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename) ||
is_bound_guest_program(target)) {
struct exec_probe probe;
const char *elf_target = select_exec_target(target, resolved_target, sizeof(resolved_target), &probe);
if (probe.is_elf && !probe.is_dynamic) static_elf = elf_target;
@@ -969,7 +970,8 @@ static int ddnatv_posix_spawn(pid_t *pid, const char *path,
}
char *const *orig_ep = envp ? envp : environ;
int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path);
int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path) ||
is_bound_guest_program(target);
struct exec_probe probe;
char resolved_target[PATH_MAX];
+8
View File
@@ -983,6 +983,14 @@ static int is_host_interpreter(const char *interp, const char *rewritten) {
return probe.android_interp;
}
static int is_bound_guest_program(const char *path) {
if (g_ddnatv_root[0] == '\0' || !is_identity_bound_path(path)) return 0;
struct exec_probe probe;
probe_exec_file(path, &probe);
if (probe.is_elf) return probe.is_dynamic && !probe.android_interp;
return probe.n >= 2 && probe.hdr[0] == '#' && probe.hdr[1] == '!';
}
// argv for running `script` with its interpreter: interp [arg] script args... (the script's own
// argv[0] is dropped, as the kernel does). free() the result.
static char **build_script_argv(const char *interp, const char *interp_arg, const char *script, char *const argv[]) {
+7
View File
@@ -234,6 +234,13 @@ static int is_mapped_guest_path(const char *path) {
return 0;
}
static int is_identity_bound_path(const char *path) {
if (!path || path[0] != '/') return 0;
for (int i = 0; i < g_nbinds; i++)
if (g_binds[i].identity && is_path_prefix(path, g_binds[i].dst, g_binds[i].dst_len)) return 1;
return 0;
}
// Android's own mounts and files, which must never be redirected into the rootfs.
// `path` starts with '/'; a prefix can only match when its second character does.
static int is_android_host_path(const char *path) {
+1
View File
@@ -32,6 +32,7 @@ def source_assets(overlay=OVERLAY):
result[desktop / name] = 'assets/linuxfs/usr/local/bin/' + name
result[desktop / 'firefox-droiddeck.js'] = 'assets/linuxfs/usr/lib/firefox/defaults/pref/droiddeck.js'
result[desktop / 'droiddeck-clipboard.desktop'] = 'assets/linuxfs/etc/xdg/autostart/droiddeck-clipboard.desktop'
result[desktop / 'droiddeck-return-gaming.desktop'] = 'assets/linuxfs/usr/share/applications/droiddeck-return-gaming.desktop'
result[desktop / 'fastfetch.jsonc'] = 'assets/linuxfs/etc/xdg/fastfetch/config.jsonc'
result[overlay.parent.parent / 'mangoapp/mangoapp'] = 'assets/linuxfs/usr/local/bin/mangoapp'
return result
+22
View File
@@ -24,6 +24,28 @@ class CiChecksTest(unittest.TestCase):
gradle = (ROOT / 'app/build.gradle').read_text()
self.assertIn("gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit])", gradle)
def test_robolectric_cache_saves_and_restores_the_same_absolute_path(self):
steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']
caches = [step['with'] for step in steps if step.get('uses', '').startswith('actions/cache')]
for cache in caches:
for path in cache['path'].split('\n'):
self.assertNotIn('..', path.split('/'))
robolectric = [cache['path'] for cache in caches if cache['key'].startswith('robolectric-')]
self.assertEqual(robolectric, ['${{ steps.robolectric-jars.outputs.path }}'] * 2)
def test_unit_test_retry_requires_maven_exception(self):
steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']
run = next(step['run'] for step in steps if step.get('id') == 'unit-tests')
line = next(line for line in run.splitlines() if 'grep -Eq' in line)
pattern = shlex.split(line)[shlex.split(line).index('-Eq') + 1]
for log, expected in (
("Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not GET 'https://repo.maven.apache.org/maven2/a.jar'. Received status code 429 from server: Too Many Requests", 0),
("Caused by: java.io.IOException: Server returned HTTP response code: 429 for URL: https://repo.maven.apache.org/maven2/a.jar", 0),
("SomeTest > test FAILED: Too Many Requests", 1),
("Caused by: java.lang.AssertionError: HTTP 429", 1),
):
self.assertEqual(subprocess.run(['grep', '-Eq', pattern], input=log, text=True).returncode, expected)
def test_report_comment_lookup_ignores_human_marker(self):
if not shutil.which('jq'):
self.skipTest('jq required to execute comment selection')
@@ -0,0 +1,293 @@
"""A commit whose dma-buf the client's GPU is still writing is held until the buffer polls readable.
The compiled functions come from compositor.c; libwayland's lists and event loop, poll and the clock are faked.
"""
import os
from pathlib import Path
import re
import shutil
import subprocess
import tempfile
import unittest
SOURCE = Path(__file__).resolve().parents[2] / 'app/src/main/cpp/waylandcomp/src/compositor.c'
def function(text, name):
match = re.search(r'^(?:static )?[^\n;]+\b' + name + r'\([^;]*?\)\s*\{', text, re.M)
if not match:
raise AssertionError('Production function not found: ' + name)
pos = text.index('{', match.start())
depth, end = 1, pos + 1
while depth:
depth += (text[end] == '{') - (text[end] == '}')
end += 1
return text[match.start():end]
def block(text, start):
begin = text.index(start)
return text[begin:text.index('\n};\n', begin) + 4]
HARNESS = r'''
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#define DAMAGE_RECTS 4
#define POLLIN 1
#define F_DUPFD_CLOEXEC 1030
#define WL_EVENT_READABLE 1
struct pollfd { int fd; short events, revents; };
struct wl_list { struct wl_list *prev, *next; };
struct wl_listener { struct wl_list link; void (*notify)(struct wl_listener *, void *); };
static void wl_list_init(struct wl_list *l) { l->prev = l->next = l; }
static void wl_list_remove(struct wl_list *l) { l->prev->next = l->next; l->next->prev = l->prev; l->prev = l->next = NULL; }
static void wl_list_insert(struct wl_list *list, struct wl_list *elm) {
elm->prev = list; elm->next = list->next; list->next = elm; elm->next->prev = elm;
}
static void wl_list_insert_list(struct wl_list *list, struct wl_list *other) {
if (other->next == other) return;
other->next->prev = list; other->prev->next = list->next; list->next->prev = other->prev; list->next = other->next;
}
static int wl_list_length(const struct wl_list *l) { int n = 0; for (struct wl_list *e = l->next; e != l; e = e->next) n++; return n; }
#define wl_container_of(ptr, sample, member) (__typeof__(sample))((char *)(ptr) - offsetof(__typeof__(*sample), member))
struct dmabuf_buffer { int fd[4]; int n_planes; int ahb; };
struct wl_resource { struct wl_list link; struct wl_listener *listener; struct dmabuf_buffer *db; int released, destroyed; };
static struct wl_resource *from_link(struct wl_list *l) { return wl_container_of(l, (struct wl_resource *)0, link); }
#define wl_resource_for_each_safe(r, t, list) \
for (r = from_link((list)->next), t = from_link(r->link.next); &r->link != (list); r = t, t = from_link(t->link.next))
static void wl_resource_destroy(struct wl_resource *r) { wl_list_remove(&r->link); r->destroyed = 1; }
static void wl_resource_add_destroy_listener(struct wl_resource *r, struct wl_listener *l) { r->listener = l; wl_list_init(&l->link); }
static void client_destroys(struct wl_resource *r) {
if (r->listener) { struct wl_listener *l = r->listener; r->listener = NULL; l->notify(l, r); }
}
static int ready[64], dup_of[64], next_dup = 40, closed[64];
static int poll(struct pollfd *p, unsigned n, int timeout) {
if (n != 1 || timeout != 0 || p->events != POLLIN) { puts("FAIL poll args"); exit(1); }
return ready[p->fd] ? 1 : 0;
}
static int fcntl(int fd, int cmd, int arg) { (void)cmd; (void)arg; dup_of[next_dup] = fd; return next_dup++; }
static int close(int fd) { closed[fd]++; return 0; }
struct wl_event_source { int fd; int (*fd_cb)(int, uint32_t, void *); int (*timer_cb)(void *); void *data; int armed_ms, removed; };
struct wl_event_loop;
struct wl_display;
static struct wl_display *g_display;
static struct wl_event_source sources[32];
static int n_sources;
static struct wl_event_loop *wl_display_get_event_loop(struct wl_display *d) { (void)d; return NULL; }
static struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *l, int fd, uint32_t mask,
int (*cb)(int, uint32_t, void *), void *data) {
(void)l; (void)mask; struct wl_event_source *s = &sources[n_sources++]; memset(s, 0, sizeof(*s));
s->fd = fd; s->fd_cb = cb; s->data = data; return s;
}
static struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *l, int (*cb)(void *), void *data) {
(void)l; struct wl_event_source *s = &sources[n_sources++]; memset(s, 0, sizeof(*s));
s->fd = -1; s->timer_cb = cb; s->data = data; return s;
}
static int wl_event_source_timer_update(struct wl_event_source *s, int ms) { s->armed_ms = ms; return 0; }
static int wl_event_source_remove(struct wl_event_source *s) { s->removed = 1; return 0; }
static void dispatch(int timers_expire) {
for (int i = 0; i < n_sources; i++) {
struct wl_event_source *s = &sources[i];
if (s->removed) continue;
if (s->fd_cb && ready[dup_of[s->fd]]) s->fd_cb(s->fd, WL_EVENT_READABLE, s->data);
else if (s->timer_cb && s->armed_ms && timers_expire) { s->armed_ms = 0; s->timer_cb(s->data); }
}
}
static int64_t clock_ns;
static int64_t now_ns(void) { return clock_ns; }
static struct { unsigned replaced; } g_pace;
static struct { unsigned commit_waits, commit_wait_limits; int64_t commit_wait_ns, commit_wait_max_ns; } g_perf;
static int logged;
static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; logged++; }
static void send_buffer_release(struct wl_resource *r) { r->released++; }
static unsigned feedback_discard_all(struct wl_list *list) {
unsigned n = 0; struct wl_resource *r, *t; wl_resource_for_each_safe(r, t, list) { wl_resource_destroy(r); n++; } return n;
}
static struct dmabuf_buffer *get_dmabuf(struct wl_resource *r) { return r ? r->db : NULL; }
static int ahb_swapchain_has_ahb(const struct dmabuf_buffer *b) { return b->ahb; }
static int64_t rect_area(const int32_t *r, int bw, int bh) { (void)bw; (void)bh; return (int64_t)r[2] * r[3]; }
struct damage_list { int32_t r[DAMAGE_RECTS][4]; int n; };
struct surface {
struct wl_resource *resource, *xdg_toplevel;
int toplevel_committed;
struct wl_resource *pending_buffer;
struct wl_listener pending_buffer_destroy;
int pending_attach, pending_src_set, pending_dst_set, pending_opaque_set;
float pending_src[4];
int pending_dst[2], pending_opaque[4];
struct damage_list pending_damage_buf, pending_damage_local;
struct wl_list pending_frames, pending_feedback;
struct surface_state *waiting;
struct wl_event_source *waiting_source, *waiting_timer;
int waiting_fd;
int64_t waiting_since_ns;
};
static void send_toplevel_configure(struct surface *s) { (void)s; }
struct wl_client;
static struct surface surf;
STATE_STRUCT
static int applies, applied_attach, applied_frames, applied_opaque, applied_damage;
static struct wl_resource *applied_buffer;
static void surface_state_apply(struct surface *s, struct surface_state *st);
FUNCTIONS
static void surface_state_apply(struct surface *s, struct surface_state *st) {
(void)s;
applies++;
applied_attach = st->attach;
applied_buffer = st->attach ? st->buffer : NULL;
applied_frames = wl_list_length(&st->frames);
applied_opaque = st->opaque_set ? st->opaque[2] : -1;
applied_damage = st->damage_buf.n;
if (st->attach) { wl_list_remove(&st->buffer_destroy.link); wl_list_init(&st->buffer_destroy.link); }
struct wl_resource *r, *t;
wl_resource_for_each_safe(r, t, &st->frames) wl_resource_destroy(r);
feedback_discard_all(&st->feedback);
}
static struct wl_resource frame_res[16];
static int n_frames;
static void attach(struct wl_resource *b) {
if (surf.pending_buffer) wl_list_remove(&surf.pending_buffer_destroy.link);
wl_list_init(&surf.pending_buffer_destroy.link);
surf.pending_buffer = b; surf.pending_attach = 1;
}
static void frame(void) { struct wl_resource *f = &frame_res[n_frames++]; wl_list_insert(surf.pending_frames.prev, &f->link); }
static void damage(int w) { surf.pending_damage_buf.r[surf.pending_damage_buf.n][2] = w;
surf.pending_damage_buf.r[surf.pending_damage_buf.n][3] = 1; surf.pending_damage_buf.n++; }
static void commit(void) { surface_commit(NULL, NULL); }
#define CHECK(c, what) do { if (!(c)) { printf("FAIL %s (line %d)\n", what, __LINE__); return 1; } } while (0)
int main(void) {
wl_list_init(&surf.pending_frames); wl_list_init(&surf.pending_feedback);
wl_list_init(&surf.pending_buffer_destroy.link);
surf.waiting_fd = -1;
struct dmabuf_buffer d1 = {{10, -1}, 1, 0}, d2 = {{11, -1}, 1, 0}, d3 = {{12, -1}, 1, 0}, dz = {{13, -1}, 1, 1};
struct wl_resource b1 = {.db = &d1}, b2 = {.db = &d2}, b3 = {.db = &d3}, bz = {.db = &dz};
ready[10] = 1;
attach(&b1); frame(); commit();
CHECK(applies == 1 && applied_buffer == &b1 && applied_frames == 1 && !surf.waiting && n_sources == 0, "ready buffer");
ready[11] = 0;
clock_ns = 1000000;
attach(&b2); frame(); damage(5); commit();
CHECK(applies == 1 && surf.waiting && surf.waiting_fd >= 40 && dup_of[surf.waiting_fd] == 11, "held");
CHECK(sources[0].armed_ms == 0 && sources[1].armed_ms == 1000, "waits on the buffer with a 1 s limit");
dispatch(0);
CHECK(applies == 1, "nothing before the writes end");
clock_ns = 4000000;
ready[11] = 1;
dispatch(0);
CHECK(applies == 2 && applied_buffer == &b2 && applied_frames == 1 && applied_damage == 1 && !surf.waiting, "applied once ready");
CHECK(closed[40] == 1 && sources[0].removed && sources[1].removed, "wait cleaned up");
CHECK(g_perf.commit_waits == 1 && g_perf.commit_wait_max_ns == 3000000, "wait counted");
ready[11] = 0; ready[12] = 0;
attach(&b2); frame(); damage(7); commit();
attach(&b3); frame(); damage(9); commit();
CHECK(applies == 2 && b2.released == 1 && dup_of[surf.waiting_fd] == 12, "replaced while waiting");
ready[12] = 1;
dispatch(0);
CHECK(applies == 3 && applied_buffer == &b3 && applied_frames == 2 && applied_damage == 2, "newest shown with both callbacks");
CHECK(g_perf.commit_waits == 2, "merged wait counted once");
ready[11] = 0;
attach(&b2); commit();
surf.pending_opaque[2] = 640; surf.pending_opaque_set = 1; frame(); commit();
CHECK(applies == 3 && b2.released == 1 && dup_of[surf.waiting_fd] == 11, "the waiting buffer is not released");
ready[11] = 1;
dispatch(0);
CHECK(applies == 4 && applied_buffer == &b2 && applied_opaque == 640 && applied_frames == 1, "buffer kept, opaque applied");
g_zero_copy_shown = &surf;
attach(&bz); commit();
CHECK(applies == 5 && applied_buffer == &bz && !surf.waiting && g_unwaited == &surf, "zero-copy buffer");
g_zero_copy_shown = NULL;
ready[13] = 0;
attach(&bz); commit();
CHECK(applies == 5 && surf.waiting, "a droiddeck-ahb buffer not shown zero-copy waits");
ready[13] = 1;
dispatch(0);
CHECK(applies == 6 && !g_unwaited, "waited buffer clears the mark");
ready[13] = 0;
ready[10] = 0;
attach(&b1); frame(); commit();
client_destroys(&b1);
ready[10] = 1;
dispatch(0);
CHECK(applies == 7 && !applied_attach && applied_frames == 1, "destroyed buffer dropped from the commit");
ready[11] = 0;
attach(&b2); commit();
dispatch(1);
CHECK(applies == 8 && applied_buffer == &b2 && g_perf.commit_wait_limits == 1 && logged == 1 && !surf.waiting, "limit");
ready[11] = 0; ready[12] = 0;
clock_ns = 10000000000;
attach(&b2); commit();
CHECK(applies == 8 && sources[n_sources - 1].armed_ms == 1000, "held again");
clock_ns += 600000000;
attach(&b3); commit();
CHECK(applies == 8 && surf.waiting && sources[n_sources - 1].armed_ms == 400, "a newer commit keeps the first deadline");
clock_ns += 500000000;
attach(&b2); commit();
CHECK(applies == 9 && applied_buffer == &b2 && g_perf.commit_wait_limits == 2 && !surf.waiting, "commits past the deadline are applied at once");
puts("PASS");
return 0;
}
'''
class CommitWaitsForClientWritesTest(unittest.TestCase):
def test_commits_wait_for_the_clients_gpu_writes(self):
compiler = shutil.which(os.environ.get('CC', 'cc'))
if not compiler:
self.skipTest('A host C compiler is required')
source = SOURCE.read_text()
functions = '\n'.join(re.search(pattern, source, re.M).group(0) for pattern in
(r'^#define COMMIT_WAIT_LIMIT_MS .*$', r'^static struct surface \*g_zero_copy_shown, \*g_unwaited;$')) + '\n' + '\n'.join(
function(source, name) for name in
('note_damage', 'on_state_buffer_destroyed', 'surface_state_take', 'state_unfinished_fd',
'surface_state_discard', 'surface_state_merge', 'surface_wait_stop', 'surface_wait_end', 'on_commit_ready',
'on_commit_wait_limit', 'surface_wait_start', 'surface_commit'))
probe = HARNESS.replace('STATE_STRUCT', block(source, 'struct surface_state {')).replace('FUNCTIONS', functions)
probe = probe.replace('struct surface *s = wl_resource_get_user_data(r);', 'struct surface *s = &surf; (void)r;')
with tempfile.TemporaryDirectory(prefix='droiddeck-commit-wait-') as temp:
folder = Path(temp)
(folder / 'probe.c').write_text(probe)
built = subprocess.run([compiler, '-std=gnu11', '-Wall', '-Wextra', '-Wno-unused-parameter', '-Wno-unused-function',
str(folder / 'probe.c'), '-o', str(folder / 'probe')],
capture_output=True, text=True)
self.assertEqual(built.returncode, 0, built.stdout + built.stderr)
run = subprocess.run([str(folder / 'probe')], capture_output=True, text=True, timeout=10)
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
self.assertEqual(run.stdout.strip(), 'PASS')
def test_scenes_settle_an_unwaited_buffer_before_copying_it(self):
body = function(SOURCE.read_text(), 'render_scene').splitlines()
copies = [i for i, line in enumerate(body) if 'vkp_render(w, h, dl.d, dl.n)' in line]
self.assertGreaterEqual(len(copies), 4)
for i in copies:
self.assertTrue(any('settle_unwaited();' in line for line in body[max(0, i - 3):i]), body[i])
text = '\n'.join(body)
self.assertIn('if (hdr_route == 1 || hdr_route == 2) settle_unwaited();', text)
self.assertIn('settle_unwaited();\n render_stream();', text)
self.assertIn('if (r == 0 && !fg_pass) g_zero_copy_shown = ls;\n else settle_unwaited();', text)
if __name__ == '__main__':
unittest.main()
+75
View File
@@ -0,0 +1,75 @@
import os
import re
import shlex
import subprocess
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
DESKTOP = ROOT / "tools/linuxfs/desktop"
SCRIPT = (DESKTOP / "droiddeck-desktop").read_text()
ENTRY = (DESKTOP / "droiddeck-return-gaming.desktop").read_text()
class DesktopReturnGamingTest(unittest.TestCase):
def session(self, logout, rc=0, bottom=False):
with tempfile.TemporaryDirectory() as tmp:
run = Path(tmp, "run")
launched = Path(tmp, "launched")
exec_line = re.search(r"^Exec=(.*)$", ENTRY, re.M).group(1)
inner = shlex.split(exec_line)[2].replace("dbus-send", "true")
plasma = Path(tmp, "plasma")
plasma.write_text("#!/bin/sh\n%s\nexit %d\n" % (inner if logout == "return" else ":", rc))
plasma.chmod(0o755)
steam = Path(tmp, "steam-launch")
steam.write_text('#!/bin/sh\necho "$*" > %s\n' % launched)
steam.chmod(0o755)
tail = SCRIPT[SCRIPT.index("return_gaming="):]
tail = tail.replace("dbus-run-session -- startplasma-wayland", str(plasma))
tail = tail.replace("/usr/local/bin/droiddeck-pipewire stop", ":")
tail = tail.replace("/usr/local/bin/droiddeck-steam-launch", str(steam))
tail = tail.replace("sleep 30", ":")
tail = tail.replace("/run/droiddeck", str(run))
plasma.write_text(plasma.read_text().replace("/run/droiddeck", str(run)))
env = {k: v for k, v in os.environ.items() if k != "DD_BOTTOM_DESKTOP"}
if bottom:
env["DD_BOTTOM_DESKTOP"] = "1"
run.mkdir()
(run / "return-gaming").write_text("")
status = subprocess.run(["sh", "-c", tail], env=env, capture_output=True, text=True).returncode
return status, launched.read_text().strip() if launched.exists() else None, (run / "return-gaming").exists()
def test_return_to_gaming_mode_opens_steam(self):
self.assertEqual(self.session("return"), (0, "bigpicture", False))
def test_log_out_goes_back_without_steam_even_after_an_earlier_request(self):
self.assertEqual(self.session("logout"), (0, None, False))
def test_a_failed_session_and_the_bottom_desktop_never_open_steam(self):
self.assertEqual(self.session("return", rc=1)[:2], (1, None))
self.assertEqual(self.session("return", bottom=True)[:2], (0, None))
def test_the_logout_request_outlives_starting_the_shutdown_service(self):
exec_line = re.search(r"^Exec=(.*)$", ENTRY, re.M).group(1)
call = shlex.split(shlex.split(exec_line)[2].split(";")[-1])
self.assertEqual(call[0], "dbus-send")
self.assertIn("--print-reply", call)
def test_a_rejected_logout_request_forgets_the_return_to_gaming_mode(self):
exec_line = re.search(r"^Exec=(.*)$", ENTRY, re.M).group(1)
with tempfile.TemporaryDirectory() as tmp:
inner = shlex.split(exec_line)[2].replace("/run/droiddeck", tmp)
for sender, kept in (("true", True), ("false", False)):
subprocess.run(["sh", "-c", inner.replace("dbus-send", sender, 1)], check=False)
self.assertEqual(Path(tmp, "return-gaming").exists(), kept)
def test_the_app_ships_the_shortcut_with_the_script(self):
source = (ROOT / "app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt").read_text()
self.assertIn('"usr/share/applications/droiddeck-return-gaming.desktop" to '
'"usr/share/applications/droiddeck-return-gaming.desktop"', source)
self.assertIn("droiddeck-return-gaming.desktop", (ROOT / "tools/release/check_session_assets.py").read_text())
if __name__ == "__main__":
unittest.main()
+21 -3
View File
@@ -29,14 +29,21 @@ PAD_TYPE_STEAM = 1
READER = r"""
#include <fcntl.h>
#include <linux/input.h>
#include <poll.h>
#include <stdio.h>
#include <sys/uio.h>
#include <unistd.h>
ssize_t __read_chk(int fd, void *buffer, size_t size, size_t buffer_size);
int __poll_chk(struct pollfd *fds, nfds_t nfds, int timeout, size_t fds_size);
static int vector_count;
static int fortified;
static ssize_t controller_read(int fd, void *buffer, size_t size)
{
if (fortified)
return __read_chk(fd, buffer, size, size);
if (!vector_count)
return read(fd, buffer, size);
struct iovec vectors[3] = {
@@ -53,7 +60,8 @@ static ssize_t controller_read(int fd, void *buffer, size_t size)
int main(int argc, char **argv)
{
vector_count = argc > 1 ? (argv[1][0] == '1' ? 1 : 3) : 0;
fortified = argc > 1 && argv[1][0] == 'f';
vector_count = argc > 1 && !fortified ? (argv[1][0] == '1' ? 1 : 3) : 0;
struct input_event events[64];
int fd = open("/dev/input/event16", O_RDONLY | O_NONBLOCK);
if (fd < 0) {
@@ -62,11 +70,17 @@ int main(int argc, char **argv)
}
while (controller_read(fd, events, sizeof(events)) > 0)
;
struct pollfd idle = {fd, POLLIN, 0};
if (fortified && __poll_chk(&idle, 1, 0, sizeof(idle)) != 0)
return 3;
puts("ready");
fflush(stdout);
char go;
if (read(0, &go, 1) != 1)
return 1;
struct pollfd ready = {fd, POLLIN, 0};
if (fortified && (__poll_chk(&ready, 1, 1000, sizeof(ready)) != 1 || !(ready.revents & POLLIN)))
return 2;
ssize_t got = controller_read(fd, events, sizeof(events));
for (ssize_t i = 0; i < got / (ssize_t)sizeof(events[0]); i++)
printf("%ld.%06ld %u %u %d\n", (long)events[i].time.tv_sec, (long)events[i].time.tv_usec, events[i].type,
@@ -345,7 +359,7 @@ class FakeinputRingTest(unittest.TestCase):
subprocess.run(["gcc", bits, "-o", str(binary), str(self.tmp / (name + ".c"))], check=True)
return library, binary
def read_through(self, bits, vectors=None, overlay=False, virtual=True, program=READER):
def read_through(self, bits, vectors=None, overlay=False, virtual=True, program=READER, fortified=False):
if not virtual:
program = program.replace("event16", "event0")
library, reader = self.build(bits, program, "reader")
@@ -359,7 +373,7 @@ class FakeinputRingTest(unittest.TestCase):
overlay_library = self.tmp / "overlay.so"
subprocess.run(["gcc", bits, "-shared", "-fPIC", "-o", str(overlay_library), str(source)], check=True)
env["LD_PRELOAD"] = str(overlay_library) + ":" + str(library)
command = [str(reader)] + ([str(vectors)] if vectors else [])
command = [str(reader)] + (["fortified"] if fortified else [str(vectors)] if vectors else [])
process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, text=True)
self.addCleanup(process.kill)
self.assertEqual(process.stdout.readline(), "ready\n")
@@ -381,6 +395,10 @@ class FakeinputRingTest(unittest.TestCase):
self.assertEqual(self.read_through("-m64"),
"1700000000.250000 1 304 1\n1700000001.250000 3 1 -32768\n1700000002.250000 0 0 0\n")
def test_a_fortified_guest_polls_and_reads_the_ring(self):
self.assertEqual(self.read_through("-m64", virtual=False, fortified=True),
"1700000000.250000 1 304 1\n1700000001.250000 3 1 -32768\n1700000002.250000 0 0 0\n")
def test_readv_reads_events_instead_of_the_backing_file(self):
self.assertEqual(self.read_through("-m64", vectors=1),
"1700000000.250000 1 304 1\n1700000001.250000 3 1 -32768\n1700000002.250000 0 0 0\n")
@@ -120,6 +120,14 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
script.parent.mkdir(exist_ok=True)
script.write_text(f"#!{interpreter}\n")
script.chmod(0o755)
cls.app_files = tmp / "app-files"
cls.app_files.mkdir()
shutil.copy(cls.probe, cls.app_files / "tool")
shutil.copy(cls.android / "sh", cls.app_files / "android-tool")
for name, interpreter in (("guest.py", GUEST_TOOL), ("android.sh", f"{ANDROID_DIR}/sh")):
(cls.app_files / name).write_text(f"#!{interpreter}\n")
for entry in cls.app_files.iterdir():
entry.chmod(0o755)
@classmethod
def tearDownClass(cls):
@@ -220,6 +228,32 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
call = self.call(how, "/opt/host.sh", "x", binds=f"{self.runtime}:{BOUND_DIR}")
self.assertEqual([HOST_SHELL, HOST_SHELL, str(self.root / "opt/host.sh"), "x"], call)
def test_a_script_on_a_mount_at_its_host_path_runs_with_the_guest_interpreter(self):
script = str(self.app_files / "guest.py")
for how in ("exec", "spawn"):
with self.subTest(how=how):
call = self.call(how, script, "x", binds=f"{self.app_files}:{self.app_files}")
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
self.assertEqual([str(self.root / GUEST_TOOL.lstrip("/")), script, "x"], call[-3:])
def test_a_glibc_program_on_a_mount_at_its_host_path_starts_through_the_guest_ldso(self):
tool = str(self.app_files / "tool")
for how in ("exec", "spawn"):
with self.subTest(how=how):
call = self.call(how, tool, "x", binds=f"{self.app_files}:{self.app_files}")
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
self.assertEqual([tool, "x"], call[-2:])
def test_android_programs_on_a_mount_at_its_host_path_stay_on_the_host(self):
tool = str(self.app_files / "android-tool")
script = str(self.app_files / "android.sh")
sh = str(self.android / "sh")
binds = f"{self.app_files}:{self.app_files}|{self.android}:{ANDROID_DIR}"
for how in ("exec", "spawn"):
with self.subTest(how=how):
self.assertEqual([tool, tool, "x"], self.call(how, tool, "x", binds=binds))
self.assertEqual([sh, sh, script, "x"], self.call(how, script, "x", binds=binds))
def test_an_android_interpreter_reached_through_a_bind_stays_on_the_host(self):
sh = str(self.android / "sh")
for how in ("exec", "spawn"):
@@ -0,0 +1,205 @@
import runpy
import tempfile
import unittest
from pathlib import Path
from unittest import mock
from tools.tests.test_droiddeck_fex import AppInfoTest
BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin"
SESSION = BIN / "droiddeck-session"
COMPAT = runpy.run_path(str(BIN / "steam-compatibility"))
EAC = 1826330
SCOUT = 1070560
EAC_ID = str(EAC)
SCOUT_ID = str(SCOUT)
EAC_NAME = "Proton EasyAntiCheat Runtime"
SCOUT_NAME = "Steam Linux Runtime 1.0 (scout)"
def tool(name, osarch="", kind="tool", installdir=None):
return {
"common": {"name": name, "oslist": "linux", "osarch": osarch, "type": kind},
"config": {"installdir": installdir or name},
}
class SteamToolManifestSeedTest(unittest.TestCase):
def setUp(self):
temporary = tempfile.TemporaryDirectory()
self.addCleanup(temporary.cleanup)
self.root = Path(temporary.name)
self.steam = self.root / "Steam"
(self.steam / "appcache").mkdir(parents=True)
(self.steam / "steamapps").mkdir()
self.entries = {EAC: tool(EAC_NAME), SCOUT: tool(SCOUT_NAME)}
self.write_appinfo()
def write_appinfo(self, entries=None):
COMPAT["APPINFO_CACHE"].clear()
(self.steam / "appcache/appinfo.vdf").write_bytes(
AppInfoTest.appinfo(self.entries if entries is None else entries))
def manifest(self, app, root=None):
return (root or self.steam) / ("steamapps/appmanifest_%s.acf" % app)
def seed(self):
return COMPAT["seed_unavailable_arm64_tools"](str(self.steam))
def test_seeds_bare_manifests_for_unavailable_tool_dependencies(self):
self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID])
for app, name in ((EAC_ID, EAC_NAME), (SCOUT_ID, SCOUT_NAME)):
text = self.manifest(app).read_text()
for expected in ('"appid" "%s"' % app, '"Universe" "1"', '"StateFlags" "4"',
'"name" "%s"' % name, '"installdir" "%s"' % name,
'"AutoUpdateBehavior" "1"'):
self.assertIn(expected, text)
self.assertFalse(self.manifest("976730").exists())
def test_seeding_is_idempotent(self):
self.seed()
first = {app: self.manifest(app).read_text() for app in (EAC_ID, SCOUT_ID)}
self.assertEqual(self.seed(), [])
self.assertEqual({app: self.manifest(app).read_text() for app in first}, first)
def test_a_real_install_in_another_library_is_never_overwritten(self):
other = self.root / "SD"
(other / "steamapps").mkdir(parents=True)
existing = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"4"\n}\n' % SCOUT_ID
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(existing)
(self.steam / "steamapps/libraryfolders.vdf").write_text(
'"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other)
self.assertEqual(self.seed(), [EAC_ID])
self.assertFalse(self.manifest(SCOUT_ID).exists())
self.assertEqual((other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text(), existing)
def test_a_partial_install_in_another_library_is_completed_in_place(self):
other = self.root / "SD"
(other / "steamapps").mkdir(parents=True)
partial = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"2"\n}\n' % SCOUT_ID
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(partial)
(self.steam / "steamapps/libraryfolders.vdf").write_text(
'"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other)
self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID])
self.assertFalse(self.manifest(SCOUT_ID).exists())
self.assertIn('"StateFlags" "4"',
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text())
def test_a_real_install_in_any_library_wins_over_a_partial_one(self):
other = self.root / "SD"
(other / "steamapps").mkdir(parents=True)
partial = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"2"\n}\n' % SCOUT_ID
installed = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"4"\n}\n' % SCOUT_ID
self.manifest(SCOUT_ID).write_text(partial)
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(installed)
(self.steam / "steamapps/libraryfolders.vdf").write_text(
'"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other)
self.assertEqual(self.seed(), [EAC_ID])
self.assertEqual(self.manifest(SCOUT_ID).read_text(), partial)
self.assertEqual((other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text(), installed)
def test_a_failed_write_leaves_no_manifest_behind(self):
real_link = COMPAT["os"].link
def fail_for_scout(source, target):
if SCOUT_ID in str(target):
raise OSError("disk full")
return real_link(source, target)
with mock.patch.object(COMPAT["os"], "link", side_effect=fail_for_scout):
self.assertEqual(self.seed(), [EAC_ID])
self.assertFalse(self.manifest(SCOUT_ID).exists())
self.assertEqual(sorted(p.name for p in (self.steam / "steamapps").iterdir()),
["appmanifest_%s.acf" % EAC_ID])
self.assertEqual(self.seed(), [SCOUT_ID])
self.assertEqual(self.manifest(SCOUT_ID).read_text(),
COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True))
def test_new_manifest_publication_preserves_a_concurrent_install(self):
real_link = COMPAT["os"].link
installed = COMPAT["manifest_text"](SCOUT_ID, "Existing tool", "Existing", False)
def publish(source, target):
if SCOUT_ID in str(target):
Path(target).write_text(installed)
return real_link(source, target)
with mock.patch.object(COMPAT["os"], "link", side_effect=publish):
self.assertEqual(self.seed(), [EAC_ID])
self.assertEqual(self.manifest(SCOUT_ID).read_text(), installed)
self.assertEqual(self.seed(), [])
self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*")))
def test_partial_staged_write_is_not_published_and_retry_repairs(self):
real_temporary = COMPAT["tempfile"].NamedTemporaryFile
def temporary(*args, **kwargs):
output = real_temporary(*args, **kwargs)
real_write = output.write
def write(text):
if SCOUT_ID in text:
real_write(text[:text.index(' "installdir"')])
output.flush()
raise OSError("disk full")
return real_write(text)
output.write = write
return output
with mock.patch.object(COMPAT["tempfile"], "NamedTemporaryFile", side_effect=temporary):
self.assertEqual(self.seed(), [EAC_ID])
self.assertFalse(self.manifest(SCOUT_ID).exists())
self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*")))
self.assertEqual(self.seed(), [SCOUT_ID])
self.assertEqual(self.manifest(SCOUT_ID).read_text(),
COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True))
def test_failed_replacement_preserves_partial_manifest_and_retry_repairs(self):
partial = '"AppState" { "appid" "%s" "StateFlags" "2" }' % SCOUT_ID
self.manifest(SCOUT_ID).write_text(partial)
with mock.patch.object(COMPAT["os"], "replace", side_effect=OSError("disk full")):
self.assertEqual(self.seed(), [EAC_ID])
self.assertEqual(self.manifest(SCOUT_ID).read_text(), partial)
self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*")))
self.assertEqual(self.seed(), [SCOUT_ID])
self.assertEqual(self.manifest(SCOUT_ID).read_text(),
COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True))
def test_tools_with_an_arm64_depot_are_skipped(self):
entries = dict(self.entries)
entries[SCOUT] = tool(SCOUT_NAME, osarch="arm64")
self.write_appinfo(entries)
self.assertEqual(self.seed(), [EAC_ID])
self.assertFalse(self.manifest(SCOUT_ID).exists())
def test_an_app_that_is_not_a_tool_is_skipped(self):
entries = dict(self.entries)
entries[SCOUT] = tool(SCOUT_NAME, kind="game")
self.write_appinfo(entries)
self.assertEqual(self.seed(), [EAC_ID])
self.assertFalse(self.manifest(SCOUT_ID).exists())
def test_missing_appinfo_uses_the_display_names(self):
(self.steam / "appcache/appinfo.vdf").unlink()
COMPAT["APPINFO_CACHE"].clear()
self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID])
self.assertIn('"name" "%s"' % SCOUT_NAME, self.manifest(SCOUT_ID).read_text())
def test_flag_seeds_without_running_full_compatibility_setup(self):
with mock.patch.object(COMPAT["sys"], "argv",
["steam-compatibility", str(self.steam), "--seed-arm64-tools"]):
COMPAT["main"]()
self.assertTrue(self.manifest(EAC_ID).is_file())
self.assertTrue(self.manifest(SCOUT_ID).is_file())
self.assertFalse((self.steam / "compatibilitytools.d").exists())
def test_session_seeds_only_on_the_arm64_client_path(self):
arm64, x64 = SESSION.read_text().split(
" else\n _dd_x64_tool=$(droiddeck-steam-x64 --default-tool)", 1)
self.assertIn('steam-compatibility "$steam_root" --seed-arm64-tools', arm64)
self.assertNotIn("--seed-arm64-tools", x64)
if __name__ == "__main__":
unittest.main()
+1 -1
View File
@@ -95,7 +95,7 @@ class SubsurfaceReleaseTest(unittest.TestCase):
def test_compositor_attach_and_commit_use_the_release_hold(self):
self.assertIn('pending_releases_cancel(buffer);', function_body(self.source, 'take_dmabuf'))
commit = function_body(self.source, 'surface_commit')
commit = function_body(self.source, 'surface_state_apply')
self.assertIn('pending_releases_apply(s);', commit)
self.assertLess(commit.index('take_dmabuf(s, db, buffer);'), commit.index('pending_releases_apply(s);'))
self.assertLess(commit.index('buf_trace_attach(buffer);'), commit.index('if (s->role == ROLE_CURSOR)'))
@@ -1,9 +0,0 @@
[Desktop Entry]
Name=Return to Gaming Mode
Comment=Log out of the desktop and go back to Steam
Exec=dbus-send --session --type=method_call --dest=org.kde.Shutdown /Shutdown org.kde.Shutdown.logout
Icon=steamdeck-gaming-return
Terminal=false
Type=Application
StartupNotify=false
NoDisplay=true