mirror of
https://github.com/InstanceBrick/nightcap.git
synced 2026-10-17 22:00:46 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4be3de14a | ||
|
|
876f8b8c32 | ||
|
|
c614fba032 | ||
|
|
046632cf99 | ||
|
|
a3a2b76a06 | ||
|
|
f333399e18 | ||
|
|
3062909209 | ||
|
|
049784d0f8 | ||
|
|
ccf910f064 | ||
|
|
23e7831149 | ||
|
|
5b2ee2c7f3 | ||
|
|
63ed62b4aa | ||
|
|
81de528668 | ||
|
|
ff81882cb0 | ||
|
|
a87373d003 | ||
|
|
b46098c211 | ||
|
|
144350090e | ||
|
|
3ed0418997 | ||
|
|
8410070eec | ||
|
|
a1166fb6ba | ||
|
|
c9eb4fb7f0 | ||
|
|
b59c070cc0 | ||
|
|
4a9acf8c49 | ||
|
|
c342bab7b5 | ||
|
|
a3b9c872a5 | ||
|
|
4f45baf3f7 | ||
|
|
0ddb546ba8 | ||
|
|
7ba752ebb7 | ||
|
|
227895faa4 | ||
|
|
dfc3c8d555 | ||
|
|
e490dff97f | ||
|
|
b5b9990017 | ||
|
|
d278c0fe0a | ||
|
|
044f97e476 | ||
|
|
321ba5b3a2 | ||
|
|
fd364a7bf2 | ||
|
|
5253563e3f | ||
|
|
551d2a1829 | ||
|
|
37b88103f4 | ||
|
|
763faed0e3 | ||
|
|
74eedada0b | ||
|
|
6cb3dd00a9 | ||
|
|
fe2f641a9e | ||
|
|
cb2e9dd598 | ||
|
|
bc108106db | ||
|
|
aa31cdf395 | ||
|
|
3e6f63ea93 | ||
|
|
bfa6811417 | ||
|
|
84502c0a1a | ||
|
|
46d1d5ffbe | ||
|
|
545fd8344f | ||
|
|
4c40fcdc99 | ||
|
|
d4c7a6f741 | ||
|
|
491925f59e | ||
|
|
2917bc5423 | ||
|
|
2451264696 | ||
|
|
a9a96c6861 | ||
|
|
5bf4eeb41b | ||
|
|
d937dd7ea6 | ||
|
|
169e65bf60 | ||
|
|
69476f0f47 | ||
|
|
79d0cdfb40 | ||
|
|
273209b9ea | ||
|
|
bbfd603e17 | ||
|
|
1ba2941e7f | ||
|
|
68c90ce428 | ||
|
|
068f07e125 | ||
|
|
a469689bbb | ||
|
|
51836a980d | ||
|
|
ad546a7781 | ||
|
|
3c45450dfc | ||
|
|
185c11b57f | ||
|
|
2c3d7b485e | ||
|
|
6f8344a28b | ||
|
|
b60c43e8f0 | ||
|
|
b5e4273277 | ||
|
|
d2858fedc8 | ||
|
|
326a0659ea | ||
|
|
dd45467056 | ||
|
|
94b1036296 | ||
|
|
4c61daad0c | ||
|
|
f5f224875a | ||
|
|
90d4891a4e | ||
|
|
46dd99266c | ||
|
|
77fce18a95 | ||
|
|
d6f0f2c755 | ||
|
|
c6afc5af24 | ||
|
|
74e7455ee1 | ||
|
|
000d021452 | ||
|
|
2eef2c3821 | ||
|
|
4928443f90 | ||
|
|
b37497db7b | ||
|
|
6bbdc39d7e | ||
|
|
1c11336ba1 | ||
|
|
b19bd8406f | ||
|
|
cd46538eb8 | ||
|
|
eca5f395eb | ||
|
|
26767e925c | ||
|
|
01a0e40463 | ||
|
|
a11e833e06 | ||
|
|
b9bce36824 | ||
|
|
14c8a55211 | ||
|
|
5c5422fa02 | ||
|
|
9b041ec2ac | ||
|
|
5f83c4a64f | ||
|
|
a9d8e3185e | ||
|
|
67a9f4db97 | ||
|
|
f07daccc82 | ||
|
|
2eef4f966f | ||
|
|
41003efb09 | ||
|
|
29a0f03a90 | ||
|
|
5a27aa0366 | ||
|
|
c99a55dc54 | ||
|
|
30d50f15d1 | ||
|
|
ab940acfb5 | ||
|
|
719b1fdd22 | ||
|
|
1fa2e116b3 | ||
|
|
35359f3575 | ||
|
|
40237fae72 | ||
|
|
ad6a3c3147 | ||
|
|
d982cd9506 | ||
|
|
65adb3bddc | ||
|
|
47e23df2e0 | ||
|
|
c0ff1842ee | ||
|
|
e073947b91 | ||
|
|
66de662e5b | ||
|
|
6c3631058c | ||
|
|
6829fd00ed | ||
|
|
8be3618cd5 | ||
|
|
265b476440 | ||
|
|
ff905fe5b7 | ||
|
|
02108a9bb1 | ||
|
|
7dd32335ca | ||
|
|
5ed6ed5e84 | ||
|
|
cef1b3ec4a | ||
|
|
854969457f |
No files matched your search
@@ -11,14 +11,14 @@ body:
|
||||
value: |
|
||||
Please include enough detail for someone else to reproduce the bug.
|
||||
|
||||
Use any language you are comfortable with. The maintainer can read Russian and English directly, so either is preferred. If you are more comfortable in another language, use it.
|
||||
Use any language you are comfortable with.
|
||||
|
||||
Please write issues and pull requests yourself. Do not use AI-generated text.
|
||||
Please write issues and pull requests yourself.
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Mocktail version
|
||||
label: Nightcap version
|
||||
description: Provide the release version, package version, or commit hash.
|
||||
placeholder: "For example: v0.4.0 or 1a2b3c4"
|
||||
validations:
|
||||
@@ -37,7 +37,7 @@ body:
|
||||
id: installation
|
||||
attributes:
|
||||
label: Installation method
|
||||
description: Tell us how Mocktail was installed or built.
|
||||
description: Tell us how Nightcap was installed or built.
|
||||
placeholder: "For example: AppImage, Flatpak, AUR, or built from source"
|
||||
validations:
|
||||
required: true
|
||||
@@ -56,7 +56,7 @@ body:
|
||||
label: Steps to reproduce
|
||||
description: List the smallest reliable sequence of actions that triggers the problem.
|
||||
placeholder: |
|
||||
1. Start Mocktail with ...
|
||||
1. Start Nightcap with ...
|
||||
2. Open ...
|
||||
3. Select ...
|
||||
4. Observe ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Modified by vii from komaruworld/mocktail. See README "About this fork".
|
||||
name: Feature request
|
||||
description: Suggest an improvement or a new capability for Mocktail
|
||||
description: Suggest an improvement or a new capability for Nightcap
|
||||
title: "[Feature]: "
|
||||
labels:
|
||||
- enhancement
|
||||
@@ -10,9 +11,9 @@ body:
|
||||
value: |
|
||||
Describe what you want to change and why it would be useful.
|
||||
|
||||
Use any language you are comfortable with. The maintainer can read Russian and English directly, so either is preferred. If you are more comfortable in another language, use it.
|
||||
Use any language you are comfortable with.
|
||||
|
||||
Please write issues and pull requests yourself. Do not use AI-generated text.
|
||||
Please write issues and pull requests yourself.
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
@@ -26,7 +27,7 @@ body:
|
||||
id: proposal
|
||||
attributes:
|
||||
label: Proposed solution
|
||||
description: Describe how you would like Mocktail to behave.
|
||||
description: Describe how you would like Nightcap to behave.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<!-- Briefly describe what this pull request adds, changes, or removes. Write it yourself and do not use AI-generated text. Link the issue with "Closes #123" or "Fixes #123". -->
|
||||
<!-- Modified by vii from komaruworld/mocktail. See README "About this fork". -->
|
||||
<!-- Briefly describe what this pull request adds, changes, or removes. Link the issue with "Closes #123" or "Fixes #123". -->
|
||||
|
||||
Closes #
|
||||
@@ -0,0 +1,119 @@
|
||||
name: Publish AUR packages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: Release tag to publish, such as v0.3.4
|
||||
required: true
|
||||
type: string
|
||||
workflow_call:
|
||||
inputs:
|
||||
tag:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
AUR_SSH_PRIVATE_KEY:
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: aur-publish
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish nightcap and nightcap-bin
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 15
|
||||
environment: release
|
||||
steps:
|
||||
- name: Check out the release
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.tag }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Render the recipes
|
||||
shell: bash
|
||||
env:
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
[[ "$TAG" =~ ^v[0-9]+(\.[0-9]+)*$ ]]
|
||||
version="${TAG#v}"
|
||||
archive="nightcap-${version}-1-x86_64.pkg.tar.zst"
|
||||
# nightcap-bin installs the pacman package from the release page, so
|
||||
# its checksum is the one published beside that asset.
|
||||
checksum="$(curl -fsSL \
|
||||
"https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/${archive}.sha256" |
|
||||
awk '{print $1}')"
|
||||
[[ "$checksum" =~ ^[0-9a-f]{64}$ ]]
|
||||
|
||||
sed -i "s/^pkgver=.*/pkgver=${version}/" \
|
||||
packaging/aur/nightcap/PKGBUILD packaging/aur/nightcap-bin/PKGBUILD
|
||||
sed -i "s/^sha256sums=('SKIP')$/sha256sums=('${checksum}')/" \
|
||||
packaging/aur/nightcap-bin/PKGBUILD
|
||||
grep -Fqx "sha256sums=('${checksum}')" packaging/aur/nightcap-bin/PKGBUILD
|
||||
|
||||
docker run --rm \
|
||||
--volume "$GITHUB_WORKSPACE/packaging/aur:/aur" \
|
||||
ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05 bash -Eeuo pipefail -c '
|
||||
useradd --create-home builder
|
||||
for package in nightcap nightcap-bin; do
|
||||
install -d -o builder -g builder "/tmp/${package}"
|
||||
install -o builder -g builder -m 0644 \
|
||||
"/aur/${package}/PKGBUILD" "/tmp/${package}/PKGBUILD"
|
||||
runuser -u builder -- bash -c \
|
||||
"cd /tmp/${package} && makepkg --printsrcinfo" \
|
||||
> "/aur/${package}/.SRCINFO"
|
||||
done
|
||||
'
|
||||
|
||||
for package in nightcap nightcap-bin; do
|
||||
grep -Fqx "pkgver=${version}" "packaging/aur/${package}/PKGBUILD"
|
||||
grep -Fqx $'\tpkgver = '"${version}" "packaging/aur/${package}/.SRCINFO"
|
||||
done
|
||||
echo "VERSION=${version}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Push to the AUR
|
||||
shell: bash
|
||||
env:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
if [[ -z "${AUR_SSH_PRIVATE_KEY}" ]]; then
|
||||
echo "::notice::AUR_SSH_PRIVATE_KEY is not set; nothing was pushed to the AUR"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ssh_dir="$(mktemp -d)"
|
||||
trap 'rm -rf "$ssh_dir"' EXIT
|
||||
install -m 0600 /dev/null "$ssh_dir/key"
|
||||
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$ssh_dir/key"
|
||||
# The AUR lists this key's fingerprint on its front page:
|
||||
# SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4
|
||||
printf '%s\n' \
|
||||
'aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN' \
|
||||
> "$ssh_dir/known_hosts"
|
||||
export GIT_SSH_COMMAND="ssh -i $ssh_dir/key -o IdentitiesOnly=yes -o UserKnownHostsFile=$ssh_dir/known_hosts -o StrictHostKeyChecking=yes"
|
||||
|
||||
for package in nightcap nightcap-bin; do
|
||||
checkout="$ssh_dir/$package"
|
||||
git clone "ssh://aur@aur.archlinux.org/${package}.git" "$checkout"
|
||||
cp "packaging/aur/${package}/PKGBUILD" "packaging/aur/${package}/.SRCINFO" \
|
||||
"$checkout/"
|
||||
git -C "$checkout" add PKGBUILD .SRCINFO
|
||||
if git -C "$checkout" diff --cached --quiet; then
|
||||
echo "::notice::${package} is already at ${VERSION}"
|
||||
continue
|
||||
fi
|
||||
git -C "$checkout" \
|
||||
-c user.name='Nightcap release' \
|
||||
-c user.email='CoderDayton@users.noreply.github.com' \
|
||||
commit --quiet -m "Update to ${VERSION}"
|
||||
# The AUR only accepts the master branch.
|
||||
git -C "$checkout" push origin HEAD:master
|
||||
done
|
||||
+16
-74
@@ -1,8 +1,6 @@
|
||||
name: Publish AUR packages
|
||||
name: Check AUR packages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -13,8 +11,8 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish AUR packages
|
||||
metadata:
|
||||
name: Refresh AUR metadata
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
@@ -27,10 +25,9 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
package_dir="$GITHUB_WORKSPACE/packaging/aur/mocktail-git"
|
||||
version="$(sed -n \
|
||||
's/^[[:space:]]*VERSION[[:space:]]\+\([0-9][0-9.]*\).*/\1/p' \
|
||||
CMakeLists.txt | head -n 1)"
|
||||
package_dir="$GITHUB_WORKSPACE/packaging/aur/nightcap-git"
|
||||
version="$(git describe --tags --abbrev=0 --match='v[0-9]*')"
|
||||
version="${version#v}"
|
||||
[[ "$version" =~ ^[0-9]+(\.[0-9]+)*$ ]]
|
||||
pkgver="${version}.r$(git rev-list --count HEAD).g$(git rev-parse --short=7 HEAD)"
|
||||
sed -i "s/^pkgver=.*/pkgver=${pkgver}/" "$package_dir/PKGBUILD"
|
||||
@@ -39,76 +36,21 @@ jobs:
|
||||
--volume "$package_dir:/pkg" \
|
||||
archlinux:base-devel bash -Eeuo pipefail -c '
|
||||
useradd --create-home builder
|
||||
install -d -o builder -g builder /tmp/mocktail-git
|
||||
install -d -o builder -g builder /tmp/nightcap-git
|
||||
install -o builder -g builder -m 0644 \
|
||||
/pkg/PKGBUILD /tmp/mocktail-git/PKGBUILD
|
||||
/pkg/PKGBUILD /tmp/nightcap-git/PKGBUILD
|
||||
runuser -u builder -- bash -c \
|
||||
"cd /tmp/mocktail-git && makepkg --printsrcinfo" \
|
||||
"cd /tmp/nightcap-git && makepkg --printsrcinfo" \
|
||||
> /pkg/.SRCINFO
|
||||
'
|
||||
|
||||
grep -Fqx "pkgver=${pkgver}" "$package_dir/PKGBUILD"
|
||||
grep -Fqx $'\tpkgver = '"${pkgver}" "$package_dir/.SRCINFO"
|
||||
printf 'AUR_PKGVER=%s\n' "$pkgver" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Publish to the AUR
|
||||
shell: bash
|
||||
env:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
AUR_SSH_KEY_PASSPHRASE: ${{ secrets.AUR_SSH_KEY_PASSPHRASE }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
[[ -n "$AUR_SSH_PRIVATE_KEY" ]]
|
||||
[[ -n "$AUR_SSH_KEY_PASSPHRASE" ]]
|
||||
|
||||
private_key="$RUNNER_TEMP/aur_ed25519"
|
||||
askpass="$RUNNER_TEMP/aur_askpass"
|
||||
known_hosts="$RUNNER_TEMP/aur_known_hosts"
|
||||
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$private_key"
|
||||
unset AUR_SSH_PRIVATE_KEY
|
||||
chmod 0600 "$private_key"
|
||||
printf '%s\n' \
|
||||
'#!/usr/bin/env bash' \
|
||||
'printf '\''%s\n'\'' "$AUR_SSH_KEY_PASSPHRASE"' \
|
||||
> "$askpass"
|
||||
chmod 0700 "$askpass"
|
||||
eval "$(ssh-agent -s)"
|
||||
trap 'ssh-agent -k >/dev/null; rm -f -- "$private_key" "$askpass"' EXIT
|
||||
DISPLAY=:0 SSH_ASKPASS="$askpass" SSH_ASKPASS_REQUIRE=force \
|
||||
ssh-add "$private_key" </dev/null
|
||||
unset AUR_SSH_KEY_PASSPHRASE
|
||||
|
||||
ssh-keyscan -T 10 -t ed25519 aur.archlinux.org > "$known_hosts"
|
||||
fingerprint="$(ssh-keygen -lf "$known_hosts" -E sha256 | awk '{print $2}')"
|
||||
[[ "$fingerprint" == \
|
||||
'SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4' ]]
|
||||
|
||||
export GIT_SSH_COMMAND="ssh -F /dev/null -i $private_key \
|
||||
-o BatchMode=yes -o IdentitiesOnly=yes \
|
||||
-o StrictHostKeyChecking=yes \
|
||||
-o UserKnownHostsFile=$known_hosts"
|
||||
publish_aur_package() {
|
||||
local package_name="$1"
|
||||
local commit_message="$2"
|
||||
local source_dir="packaging/aur/$package_name"
|
||||
local aur_dir="$RUNNER_TEMP/${package_name}-aur"
|
||||
|
||||
git clone --branch master --single-branch \
|
||||
"ssh://aur@aur.archlinux.org/${package_name}.git" "$aur_dir"
|
||||
install -m 0644 "$source_dir/PKGBUILD" "$aur_dir/PKGBUILD"
|
||||
install -m 0644 "$source_dir/.SRCINFO" "$aur_dir/.SRCINFO"
|
||||
|
||||
git -C "$aur_dir" config user.name komaruworld
|
||||
git -C "$aur_dir" config user.email rtysus228@gmail.com
|
||||
git -C "$aur_dir" add PKGBUILD .SRCINFO
|
||||
if git -C "$aur_dir" diff --cached --quiet; then
|
||||
printf '%s is already published\n' "$package_name"
|
||||
return
|
||||
fi
|
||||
git -C "$aur_dir" commit -m "$commit_message"
|
||||
git -C "$aur_dir" push origin HEAD:master
|
||||
}
|
||||
|
||||
publish_aur_package mocktail-git "Update to ${AUR_PKGVER}"
|
||||
publish_aur_package mocktail 'make builds stable'
|
||||
publish_aur_package mocktail-bin 'make builds stable'
|
||||
- name: Upload AUR metadata
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: Nightcap-AUR
|
||||
path: packaging/aur/nightcap-git/.SRCINFO
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
@@ -8,22 +8,32 @@ on:
|
||||
- 'CMakeLists.txt'
|
||||
- 'Makefile'
|
||||
- 'README.md'
|
||||
- '.gitmodules'
|
||||
- 'cmake/**'
|
||||
- 'config/**'
|
||||
- 'include/**'
|
||||
- 'packaging/**'
|
||||
- 'scripts/**'
|
||||
- 'src/**'
|
||||
- 'stubs/**'
|
||||
- 'tests/**'
|
||||
- 'third_party/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- 'CMakeLists.txt'
|
||||
- 'Makefile'
|
||||
- 'README.md'
|
||||
- '.gitmodules'
|
||||
- 'cmake/**'
|
||||
- 'config/**'
|
||||
- 'include/**'
|
||||
- 'packaging/**'
|
||||
- 'scripts/**'
|
||||
- 'src/**'
|
||||
- 'stubs/**'
|
||||
- 'tests/**'
|
||||
- 'third_party/**'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -65,3 +75,54 @@ jobs:
|
||||
bash tests/flatpak_packaging_test.sh .
|
||||
bash tests/native_packaging_test.sh .
|
||||
bash tests/anylinux_dependencies_test.sh .
|
||||
|
||||
native-build:
|
||||
name: Native build (${{ matrix.arch }})
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86_64
|
||||
runner: ubuntu-26.04
|
||||
- arch: aarch64
|
||||
runner: ubuntu-26.04-arm
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install build dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --yes --no-install-recommends \
|
||||
build-essential binutils cmake git ninja-build pkg-config lld \
|
||||
libsdl3-dev libsdl3-ttf-dev libcurl4-openssl-dev libssl-dev \
|
||||
nlohmann-json3-dev libyaml-dev libelf-dev libminizip-dev \
|
||||
libcapstone-dev libgtk-4-dev libadwaita-1-dev libwebkitgtk-6.0-dev \
|
||||
libutf8proc-dev libfontconfig1-dev libegl-dev libvulkan-dev \
|
||||
libplacebo-dev libpng-dev zlib1g-dev \
|
||||
xvfb xauth libgl1-mesa-dri jq patchelf
|
||||
|
||||
- name: Build and check native executables
|
||||
shell: bash
|
||||
run: |
|
||||
test "$(uname -m)" = "${{ matrix.arch }}"
|
||||
cmake -S . -B build-ci -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
|
||||
cmake --build build-ci --parallel 4
|
||||
./build-ci/mocktail --help
|
||||
./build-ci/mocktail_updater status
|
||||
|
||||
- name: Run C++ and integration tests
|
||||
shell: bash
|
||||
env:
|
||||
SDL_AUDIODRIVER: dummy
|
||||
SDL_VIDEODRIVER: x11
|
||||
LIBGL_ALWAYS_SOFTWARE: '1'
|
||||
run: |
|
||||
xvfb-run -a ctest --test-dir build-ci --output-on-failure \
|
||||
--parallel 4 --timeout 120
|
||||
@@ -38,6 +38,9 @@ jobs:
|
||||
name: Flatpak build
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 120
|
||||
# The signing key lives in the release environment, which only main and
|
||||
# v* tags may use. Builds that do not publish run without it.
|
||||
environment: ${{ (startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')) && 'release' || '' }}
|
||||
env:
|
||||
# Publish on release tags and on manual runs from main. Pull requests
|
||||
# only verify that the manifest still builds.
|
||||
|
||||
@@ -44,6 +44,8 @@ jobs:
|
||||
if: needs.probe.outputs.build == 'true'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 90
|
||||
env:
|
||||
UPINFO: gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|continuous|Nightcap-nightly-x86_64.AppImage.zsync
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
@@ -60,6 +62,7 @@ jobs:
|
||||
--volume "$GITHUB_WORKSPACE:/workspace" \
|
||||
--workdir /workspace \
|
||||
--env GH_TOKEN \
|
||||
--env UPINFO \
|
||||
ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05 bash -Eeuo pipefail -c '
|
||||
pacman -Syu --noconfirm --needed \
|
||||
cmake git ninja pkgconf lld sdl3 sdl3_ttf curl openssl \
|
||||
@@ -123,11 +126,12 @@ jobs:
|
||||
export RUNTIME=/tmp/uruntime
|
||||
export DWARFS_CMD=/tmp/mkdwarfs
|
||||
make appimage BUILD_DIR=build-appimage JOBS=4 \
|
||||
APPIMAGE=dist/Mocktail-x86_64.AppImage \
|
||||
APPIMAGE=dist/Nightcap-nightly-x86_64.AppImage \
|
||||
PORTABLE_MODE=standalone APPIMAGE_FORMAT=anylinux \
|
||||
ANYLINUX_PACKAGER=/tmp/quick-sharun \
|
||||
ANYLINUX_APPIMAGETOOL=/tmp/appimagetool
|
||||
test -x dist/Mocktail-x86_64.AppImage
|
||||
test -x dist/Nightcap-nightly-x86_64.AppImage
|
||||
test -s dist/Nightcap-nightly-x86_64.AppImage.zsync
|
||||
'
|
||||
|
||||
- name: Smoke-test AppImage without FUSE
|
||||
@@ -140,14 +144,17 @@ jobs:
|
||||
export XDG_CACHE_HOME="$smoke_dir/cache"
|
||||
export XDG_STATE_HOME="$smoke_dir/state"
|
||||
mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" "$XDG_STATE_HOME"
|
||||
timeout 60s dist/Mocktail-x86_64.AppImage --appimage-extract-and-run --help
|
||||
timeout 60s dist/Mocktail-x86_64.AppImage --appimage-extract-and-run mocktail_updater status
|
||||
test "$(dist/Nightcap-nightly-x86_64.AppImage --appimage-updateinformation)" = "$UPINFO"
|
||||
timeout 60s dist/Nightcap-nightly-x86_64.AppImage --appimage-extract-and-run --help
|
||||
timeout 60s dist/Nightcap-nightly-x86_64.AppImage --appimage-extract-and-run mocktail_updater status
|
||||
|
||||
- name: Upload AppImage
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: Nightcap-AppImage
|
||||
path: dist/Mocktail-x86_64.AppImage
|
||||
path: |
|
||||
dist/Nightcap-nightly-x86_64.AppImage
|
||||
dist/Nightcap-nightly-x86_64.AppImage.zsync
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
@@ -173,13 +180,14 @@ jobs:
|
||||
name: Nightcap-AppImage
|
||||
path: release
|
||||
|
||||
- name: Name and checksum the nightly build
|
||||
- name: Checksum the nightly build
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
# The Makefile builds under upstream's artifact name; the published
|
||||
# asset carries this fork's.
|
||||
mv -- release/Mocktail-x86_64.AppImage release/Nightcap-nightly-x86_64.AppImage
|
||||
# The .zsync file names the AppImage it updates, so the build already
|
||||
# carries the published name.
|
||||
test -s release/Nightcap-nightly-x86_64.AppImage
|
||||
test -s release/Nightcap-nightly-x86_64.AppImage.zsync
|
||||
(cd release && sha256sum Nightcap-nightly-x86_64.AppImage \
|
||||
> Nightcap-nightly-x86_64.AppImage.sha256)
|
||||
find release -maxdepth 1 -type f -print
|
||||
@@ -206,7 +214,7 @@ jobs:
|
||||
# Drop assets left by earlier runs under other names.
|
||||
while IFS= read -r asset; do
|
||||
case "$asset" in
|
||||
Nightcap-nightly-x86_64.AppImage|Nightcap-nightly-x86_64.AppImage.sha256)
|
||||
Nightcap-nightly-x86_64.AppImage|Nightcap-nightly-x86_64.AppImage.zsync|Nightcap-nightly-x86_64.AppImage.sha256)
|
||||
;;
|
||||
*)
|
||||
gh release delete-asset continuous "$asset" --yes
|
||||
|
||||
@@ -126,10 +126,153 @@ jobs:
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
deb:
|
||||
name: DEB (Ubuntu 26.04)
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Build DEB
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
docker run --rm \
|
||||
--volume "$GITHUB_WORKSPACE:/workspace" \
|
||||
--workdir /workspace \
|
||||
--env MOCKTAIL_PACKAGE_VERSION="$(./scripts/package_version.sh)" \
|
||||
ubuntu:26.04 bash -Eeuo pipefail -c '
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install --yes --no-install-recommends \
|
||||
build-essential cmake git ninja-build pkg-config lld fakeroot \
|
||||
dpkg-dev file libsdl3-dev libsdl3-ttf-dev \
|
||||
libcurl4-openssl-dev libssl-dev nlohmann-json3-dev \
|
||||
libyaml-dev libelf-dev libminizip-dev libcapstone-dev \
|
||||
libgtk-4-dev libadwaita-1-dev libwebkitgtk-6.0-dev \
|
||||
libutf8proc-dev libfontconfig1-dev libegl-dev \
|
||||
libvulkan-dev libplacebo-dev zlib1g-dev libpng-dev
|
||||
cmake -S . -B build-deb -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DMOCKTAIL_PACKAGE_NAME=nightcap \
|
||||
-DMOCKTAIL_PACKAGE_VERSION="$MOCKTAIL_PACKAGE_VERSION" \
|
||||
-DBUILD_TESTING=OFF
|
||||
cmake --build build-deb --parallel 4
|
||||
cpack --config build-deb/CPackConfig.cmake \
|
||||
-G DEB -B dist/deb
|
||||
dpkg-deb --info dist/deb/*.deb >/dev/null
|
||||
'
|
||||
|
||||
- name: Upload DEB
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: Nightcap-DEB
|
||||
path: dist/deb/*.deb
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
rpm:
|
||||
name: RPM (Fedora 44)
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Build RPM
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
docker run --rm \
|
||||
--volume "$GITHUB_WORKSPACE:/workspace" \
|
||||
--workdir /workspace \
|
||||
--env MOCKTAIL_PACKAGE_VERSION="$(./scripts/package_version.sh)" \
|
||||
fedora:44 bash -Eeuo pipefail -c '
|
||||
dnf install --assumeyes \
|
||||
gcc-c++ cmake git ninja-build pkgconf-pkg-config lld rpm-build \
|
||||
SDL3-devel SDL3_ttf-devel libcurl-devel openssl-devel \
|
||||
nlohmann-json-devel libyaml-devel elfutils-libelf-devel \
|
||||
minizip-ng-compat-devel capstone-devel gtk4-devel libadwaita-devel \
|
||||
webkitgtk6.0-devel utf8proc-devel fontconfig-devel \
|
||||
libglvnd-devel vulkan-headers vulkan-loader-devel \
|
||||
libplacebo-devel zlib-ng-compat-devel libpng-devel
|
||||
cmake -S . -B build-rpm -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
-DMOCKTAIL_PACKAGE_NAME=nightcap \
|
||||
-DMOCKTAIL_PACKAGE_VERSION="$MOCKTAIL_PACKAGE_VERSION" \
|
||||
-DBUILD_TESTING=OFF
|
||||
cmake --build build-rpm --parallel 4
|
||||
cpack --config build-rpm/CPackConfig.cmake \
|
||||
-G RPM -B dist/rpm
|
||||
rpm --query --package --info dist/rpm/*.rpm >/dev/null
|
||||
'
|
||||
|
||||
- name: Upload RPM
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: Nightcap-RPM
|
||||
path: dist/rpm/*.rpm
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
arch:
|
||||
name: Pacman package (Arch Linux)
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Build pacman package
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
version="$(./scripts/package_version.sh)"
|
||||
sed -i "s/^pkgver=.*/pkgver=${version}/" packaging/arch/PKGBUILD
|
||||
docker run --rm \
|
||||
--volume "$GITHUB_WORKSPACE:/workspace" \
|
||||
--workdir /workspace \
|
||||
ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05 bash -Eeuo pipefail -c '
|
||||
pacman -Syu --needed --noconfirm \
|
||||
cmake git ninja pkgconf lld sdl3 sdl3_ttf curl openssl \
|
||||
nlohmann-json libyaml libelf minizip capstone gtk4 \
|
||||
libadwaita webkitgtk-6.0 libutf8proc fontconfig libpng \
|
||||
libplacebo vulkan-headers vulkan-icd-loader libglvnd zlib
|
||||
useradd --create-home builder
|
||||
chown -R builder:builder /workspace
|
||||
runuser -u builder -- env MOCKTAIL_SOURCE_DIR=/workspace \
|
||||
makepkg --dir /workspace/packaging/arch \
|
||||
--noconfirm --cleanbuild --force
|
||||
install -d dist/arch
|
||||
cp packaging/arch/*.pkg.tar.zst dist/arch/
|
||||
pacman -Qp dist/arch/*.pkg.tar.zst >/dev/null
|
||||
'
|
||||
|
||||
- name: Upload pacman package
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: Nightcap-Arch
|
||||
path: dist/arch/*.pkg.tar.zst
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
publish:
|
||||
name: Publish GitHub release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
needs: [appimage]
|
||||
needs: [appimage, deb, rpm, arch]
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 15
|
||||
permissions:
|
||||
@@ -138,6 +281,13 @@ jobs:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Download packages
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
pattern: 'Nightcap-*'
|
||||
merge-multiple: true
|
||||
path: release
|
||||
|
||||
- name: Download AppImage
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
@@ -152,7 +302,28 @@ jobs:
|
||||
set -Eeuo pipefail
|
||||
tag="${GITHUB_REF_NAME}"
|
||||
mv release/Mocktail-x86_64.AppImage release/Nightcap-x86_64.AppImage
|
||||
(cd release && sha256sum Nightcap-x86_64.AppImage > Nightcap-x86_64.AppImage.sha256)
|
||||
# An unmatched glob would otherwise reach sha256sum and gh as its own
|
||||
# literal text, so every package pattern has to match before upload.
|
||||
shopt -s nullglob
|
||||
assets=(Nightcap-x86_64.AppImage)
|
||||
for glob in '*.deb' '*.rpm' '*.pkg.tar.zst'; do
|
||||
matched=(release/$glob)
|
||||
if [[ ${#matched[@]} -eq 0 ]]; then
|
||||
echo "::error::no ${glob} package among the release artifacts"
|
||||
exit 1
|
||||
fi
|
||||
assets+=("${matched[@]#release/}")
|
||||
done
|
||||
uploads=()
|
||||
for asset in "${assets[@]}"; do
|
||||
uploads+=("release/$asset" "release/$asset.sha256")
|
||||
done
|
||||
(
|
||||
cd release
|
||||
for asset in "${assets[@]}"; do
|
||||
sha256sum "$asset" > "$asset.sha256"
|
||||
done
|
||||
)
|
||||
./scripts/release_notes.sh "$tag" > release/notes.md
|
||||
# The Flatpak workflow creates the same release; whichever job
|
||||
# arrives second sees "already exists" and continues.
|
||||
@@ -164,5 +335,16 @@ jobs:
|
||||
gh release edit "$tag" --repo "$GITHUB_REPOSITORY" \
|
||||
--title "Nightcap $tag" --notes-file release/notes.md
|
||||
gh release upload "$tag" --repo "$GITHUB_REPOSITORY" --clobber \
|
||||
release/Nightcap-x86_64.AppImage \
|
||||
release/Nightcap-x86_64.AppImage.sha256
|
||||
"${uploads[@]}"
|
||||
|
||||
# nightcap-bin downloads the pacman package from the release page, so this
|
||||
# waits for the upload.
|
||||
aur:
|
||||
name: Publish AUR packages
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
needs: publish
|
||||
uses: ./.github/workflows/aur-publish.yml
|
||||
with:
|
||||
tag: ${{ github.ref_name }}
|
||||
secrets:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
@@ -177,3 +177,6 @@ lsan.log*
|
||||
# Test fixtures
|
||||
!/third_party/mcpelauncher-linker/core/libziparchive/**/*.zip
|
||||
!/third_party/mcpelauncher-linker/core/libziparchive/**/*.apk
|
||||
|
||||
# Working plans, not part of the shipped documentation
|
||||
/docs/plans/
|
||||
+266
-96
@@ -1,103 +1,275 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to Nightcap. The format follows
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Release notes on
|
||||
GitHub are taken from the matching section here.
|
||||
All notable changes to Nightcap. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
Release notes on GitHub are taken from the matching section here.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- An asset overlay folder, `~/.local/share/mocktail/asset_overlay`. A file there replaces the file Roblox
|
||||
ships at the same path, such as a cursor, a font or a sky texture, and it stays in place when Roblox
|
||||
updates. The layout matches Sober's `asset_overlay` folder. `MOCKTAIL_ASSET_OVERLAY_DIR` moves it. Thanks to
|
||||
@dim-ghub.
|
||||
- The asset overlay folder now also replaces files Roblox downloads and no longer ships, such as the shift
|
||||
lock and text cursors. Put the file under `content/`, at the path Roblox uses. Thanks to @dim-ghub for the
|
||||
idea.
|
||||
- `MOCKTAIL_ASSET_TRACE=1` now also prints the files Roblox asks for and does not get, as `[asset] miss`.
|
||||
- Arch Linux: `nightcap-git` is on the AUR and builds the current `main` branch. Thanks to @dim-ghub, who
|
||||
maintains it.
|
||||
- The log now names each Roblox Java call that Nightcap has no handler for, once per call, as
|
||||
`[JNI] no handler for <class>.<method><signature>`. This shows what a new Roblox version needs.
|
||||
- `--profile` traces now show how much GPU memory decoded ETC2 textures take, as the `emulated texture (MB)`
|
||||
and `compressed texture (MB)` counters. `scripts/summarize_profile_trace.py` prints the peak of each.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Joining a game from a website link while already in a game no longer freezes Nightcap. It leaves the
|
||||
current game and joins the new one, and leaving that game returns to the home screen.
|
||||
|
||||
### Changed
|
||||
|
||||
- The home screen and avatar editor have fewer long frames. PC profiles compile the app's menu scripts to
|
||||
native code and turn this off while you are in a game, so games run as before. Set
|
||||
`FFlagDebugLuauCodegenAll` in `fflags.json` to choose it yourself.
|
||||
- Nightcap answers Roblox's Java calls with less work per call, and the audio thread no longer allocates
|
||||
memory for each block of sound it plays.
|
||||
|
||||
## [0.3.4] - 2026-10-11
|
||||
|
||||
### Added
|
||||
|
||||
- The AppImage build now makes a `.zsync` file, so tools like `appimageupdatetool` can update the AppImage.
|
||||
- The desktop side panel menu now shows by default on PC profiles. Set `FIntFlyoutTestVariantRollout12` in
|
||||
`fflags.json` to change it.
|
||||
|
||||
### Changed
|
||||
|
||||
- The Flatpak build asks for the X11 socket only when there is no Wayland session, as before 0.3.3.
|
||||
- Nightcap now uses Wayland on a Wayland session with NVIDIA drivers too, however it is started. It used to
|
||||
fall back to X11 there when started from a terminal.
|
||||
- Building Nightcap no longer needs libexecinfo.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Roblox 2.742 being rejected as an update, which left the game on the older version. Nightcap now
|
||||
accepts Roblox versions that change the order of their start-up steps.
|
||||
- Fixed Nightcap reporting Mocktail's version number, 1.0.4, in session logs and support bundles. It now
|
||||
reports its own version.
|
||||
- Fixed the old Roblox home screen showing instead of the new one with the Me tab and the "For you" and
|
||||
"Charts" tabs. Nightcap now runs the Roblox start-up step that loads the new interface for your account.
|
||||
- Fixed anti-aliasing being forced off at every graphics quality level. Roblox now picks it, and a
|
||||
`FIntDebugForceMSAASamples` value in `fflags.json` still applies. Thanks to @qutad.
|
||||
- Fixed the voice chat microphone only working on Roblox 2.738. It no longer depends on one Roblox version.
|
||||
- Fixed other players not hearing you in voice chat after a Roblox update. The updater now rebuilds the
|
||||
audio device data when the previous version's profile has none.
|
||||
- Fixed frame hitches while textures load on graphics cards that need ETC2 textures decoded on the CPU.
|
||||
- Fixed problems on Chimera Linux and other musl systems, including error messages that differed from the
|
||||
ones Roblox expects.
|
||||
- Fixed the nightly AppImage build failing when a bundled GTK 4 was older than the one libadwaita needs.
|
||||
- Fixed a random crash on Wayland with NVIDIA drivers, where the game window closed after you let go of the
|
||||
camera or left mouse lock. The log showed `wp_linux_drm_syncobj_surface_v1` error 3.
|
||||
- Fixed some menu actions being ignored. The Chat button on a profile now opens the Party tab with that
|
||||
player, and clicking a search suggestion now runs the search instead of closing the search menu.
|
||||
- Fixed possible crashes when the game calls an Android function Nightcap did not provide, or releases the
|
||||
same reference twice.
|
||||
- Fixed a possible hang on close when a web view process stayed open. Nightcap now stops waiting for the log
|
||||
writer after 2 seconds.
|
||||
- Fixed a possible missing picture on graphics drivers that reject the low-latency present mode. Nightcap now
|
||||
retries with the game's own mode.
|
||||
- Fixed a possible Wayland crash when the window first appears on the OpenGL graphics path.
|
||||
- Fixed a missing picture on machines where the graphics card runs a different driver than the one Nightcap
|
||||
picked, such as an NVIDIA card on nouveau or a laptop with an Intel chip and an older second card. Nightcap
|
||||
now picks the Vulkan driver that matches the running kernel driver, and says so when no card can run Vulkan.
|
||||
|
||||
## [0.3.3] - 2026-10-04
|
||||
|
||||
### Added
|
||||
|
||||
- Joining a friend from a Roblox "follow user" link now works. Nightcap looks up which game they are in and
|
||||
joins it.
|
||||
- Nix users get a desktop entry for the app.
|
||||
|
||||
### Changed
|
||||
|
||||
- Roblox textures now decode about 3 times faster, which shortens the stalls when a place loads and when new
|
||||
parts of the map stream in. Thanks to @glook9001.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `make update-roblox` no longer deletes your previous Roblox install when an import fails partway through. If
|
||||
a step fails, the old files are put back, or kept in a folder whose path is printed. Thanks to @kimlherme.
|
||||
- A failed Roblox update now restores your previous version's records instead of leaving them half switched. A
|
||||
damaged version file is rejected instead of being half read, and a temporary failure to start the startup
|
||||
check no longer marks a working Roblox build as broken for good. Thanks to @kimlherme.
|
||||
- Fixed a possible crash when Roblox clears its audio queue while sound is still playing, and a memory leak in
|
||||
lists of objects passed to Roblox's Java code. Thanks to @kimlherme.
|
||||
- Fixed a possible crash when the text overlay shuts down, a freeze when Roblox releases the mouse lock while
|
||||
another release is already in progress, and network lookups that misread Roblox's options. Thanks to
|
||||
@kimlherme.
|
||||
- Fixed the sky sometimes rendering with the wrong textures in the Vulkan renderer.
|
||||
- Clicking while a Roblox text box has focus no longer closes it. Only Roblox decides when a click ends
|
||||
typing.
|
||||
- Going to another page in the web view, such as Friends from a profile, no longer closes the web view. It
|
||||
crashed on every page change on Wayland systems whose GL setup GTK could not use.
|
||||
- Fixed a crash when Roblox's saved dark or light theme setting was missing or damaged.
|
||||
|
||||
## [0.3.2] - 2026-09-29
|
||||
|
||||
### Added
|
||||
|
||||
- Performance recordings made with `--profile` now show how busy the CPU was during each frame, which makes it
|
||||
easier to tell what caused a stutter.
|
||||
- Experimental support for ARM64 (`aarch64`) Linux, running Roblox's Android `arm64-v8a` client.
|
||||
|
||||
### Fixed
|
||||
|
||||
- When Roblox asks for a Google Play device check during login, Nightcap now answers right away that it isn't
|
||||
supported. Before, the "Verifying you're not a bot" screen waited about a minute for an answer and then sent
|
||||
you back to the login screen.
|
||||
- Solving a login challenge now closes its window. Before, Roblox's "challenge completed" signal was ignored
|
||||
and the window stayed open. Thanks to @glook9001.
|
||||
- Login no longer stalls after you pass a verification check. Before, Roblox only saw the page's "challenge
|
||||
completed" signal after a one-minute timeout, so it gave up and the login failed. On a Roblox build Nightcap
|
||||
can't handle this way, the log says "WebViewProtocol getter not recognized" and web pages behave as before.
|
||||
- Login check windows and other web pages get 5 seconds to start instead of 3, so a slow start no longer
|
||||
closes them. The log says how long each one took to open.
|
||||
- Less stutter while joining a game and while textures load in. In Blade Ball, loading hitches dropped by
|
||||
about half, and the worst one went from 0.8 seconds to 0.55 seconds.
|
||||
- Clicking Play on a private server now joins right away. Before, nothing happened until you clicked a sidebar
|
||||
tab like Home.
|
||||
- Middle click now reaches Roblox as the middle mouse button.
|
||||
- Scrolling follows your system's natural scrolling setting.
|
||||
- Fixed a crash on some x86_64 hosts when Roblox asked about a thread other than the one making the call.
|
||||
- Roblox updates no longer mix up the ARM64 and x86_64 compatibility profiles for the same version.
|
||||
- A partial or out-of-range user id in `MOCKTAIL_ROBLOX_USER_ID` or `MOCKTAIL_LOCAL_STORAGE_CURRENT_USER_ID`
|
||||
is now ignored instead of being partly read.
|
||||
|
||||
### Changed
|
||||
|
||||
- `make flatpak` and `scripts/build_flatpak.sh` now build with 2 jobs by default instead of 4, so a local
|
||||
Flatpak build is less likely to run out of memory. Set `FLATPAK_JOBS` or `MOCKTAIL_FLATPAK_JOBS` to use
|
||||
more. Thanks to @glook9001.
|
||||
|
||||
## [0.3.1] - 2026-09-20
|
||||
|
||||
### Added
|
||||
|
||||
- Each release carries a DEB, an RPM, and a pacman package beside the AppImage, with a `.sha256` for every
|
||||
file. They install `/usr/bin/mocktail` and conflict with each other and with upstream's `mocktail` package.
|
||||
Nightcap is in no distribution repository or the AUR; the recipes under `packaging/aur/nightcap{,-bin,-git}`
|
||||
build from this repository locally.
|
||||
- The AppStream metadata lists the Nightcap releases, so software centres show the release history instead of
|
||||
upstream's.
|
||||
|
||||
### Fixed
|
||||
|
||||
- ETC2 texture decoding no longer blocks the thread that submits the frame. Uploads decode on a background
|
||||
dispatcher and the submit carries a timeline semaphore wait, so the GPU waits for the texture instead of the
|
||||
render thread. Reading the application's compressed bytes moves to that dispatcher too whenever they are
|
||||
already mapped. In Blade Ball the worst `vkQueueSubmit` fell from 140ms to 1ms, its p99 from 4.9ms to
|
||||
0.05ms, and the total time spent in submits from 2534ms to 309ms. Frame interval is unchanged: the remaining
|
||||
tail is the engine's own main-thread step. A device without the `timelineSemaphore` feature decodes inline
|
||||
as before, as does a submit whose `pNext` already sizes arrays by its semaphore counts.
|
||||
- The mouse pointer jumped when a right-click camera drag ended, and drifted to the viewport edge during one.
|
||||
The input router inferred pointer capture from SDL reporting zero absolute coordinates, which holds on X11
|
||||
but not on Wayland, where the reported position accumulates the relative deltas and leaves the window.
|
||||
Motion, button, and wheel events now carry the window's relative mouse mode. The right-click camera fallback
|
||||
also only captures inside an experience, so the cursor stays free over the app surface.
|
||||
- Shutting the window down while an experience was starting or leaving could free the pointer capture owner
|
||||
underneath the thread using it. Callers off the SDL thread now hold a reference for the length of their
|
||||
call.
|
||||
- The TextBox caret did not move when a trailing space was typed in a single-line field. The final cluster
|
||||
rect SDL_ttf reports stops at the last inked glyph, so the laid-out width is used there instead. Wrapped
|
||||
layouts keep the clamp, because their width is the widest line rather than the last.
|
||||
- Every TextBox keystroke re-ran `TTF_Init`, a fontconfig sort, six `TTF_OpenFont` calls, and `TTF_Quit` on
|
||||
the render thread. The overlay holds its opened fonts and reopens them only when the Roblox font or the
|
||||
point size changes, keeping the current set when a reopen fails. Measured over 100 rasters, 1.59ms to 0.12ms
|
||||
per keystroke.
|
||||
- Staged ETC2 copies now carry an explicit host-write barrier. A queue submission only makes host writes from
|
||||
before it visible to the device, and an asynchronous decode writes after the submit, so without the barrier
|
||||
those texels were not guaranteed to reach the copy that reads them.
|
||||
|
||||
### Changed
|
||||
|
||||
- `docs/PERFORMANCE.md` documents the GameMode settings to run with. A `desiredgov=powersave` in
|
||||
`~/.config/gamemode.ini` overrides the packaged `performance` default and clocks the CPU down for the whole
|
||||
session while still reporting an active performance request.
|
||||
|
||||
## [0.3.0] - 2026-09-18
|
||||
|
||||
### Added
|
||||
|
||||
- Custom Discord presence. `integrations.discord_rpc.text.title` replaces the
|
||||
name in "Playing Nightcap", and `integrations.discord_rpc.images` sets the
|
||||
large and small icons and their hover text. Text and image fields accept
|
||||
`{place_name}`, `{place_icon}`, and `{creator_name}`. A field that expands
|
||||
an empty placeholder is left out, and `text.state: ""` hides the state line.
|
||||
- The default Discord card now matches Sober: the title is "Roblox", the
|
||||
details line is "Playing <experience>", the state is "by <creator>", and
|
||||
the Roblox badge sits inside the experience icon. The creator comes from the
|
||||
same Roblox games request that already fetches the experience name. With
|
||||
`show_place_name: false` the creator is hidden too, so the card shows only
|
||||
the title and timer.
|
||||
- `--profile <file>` writes a Chrome-format trace of the Vulkan adapter's
|
||||
work: presents, GPU waits, submits, ETC2 texture decode, and pipeline and
|
||||
shader creation. Open it in ui.perfetto.dev. `docs/BENCHMARKING.md`
|
||||
describes the benchmark runs, and `scripts/summarize_profile_trace.py`
|
||||
turns traces into a before and after table.
|
||||
- Custom Discord presence. `integrations.discord_rpc.text.title` replaces the name in "Playing Nightcap", and
|
||||
`integrations.discord_rpc.images` sets the large and small icons and their hover text. Text and image fields
|
||||
accept `{place_name}`, `{place_icon}`, and `{creator_name}`. A field that expands an empty placeholder is
|
||||
left out, and `text.state: ""` hides the state line.
|
||||
- The default Discord card now matches Sober: the title is "Roblox", the details line is "Playing
|
||||
<experience>", the state is "by <creator>", and the Roblox badge sits inside the experience icon. The
|
||||
creator comes from the same Roblox games request that already fetches the experience name. With
|
||||
`show_place_name: false` the creator is hidden too, so the card shows only the title and timer.
|
||||
- `--profile <file>` writes a Chrome-format trace of the Vulkan adapter's work: presents, GPU waits, submits,
|
||||
ETC2 texture decode, and pipeline and shader creation. Open it in ui.perfetto.dev. `docs/BENCHMARKING.md`
|
||||
describes the benchmark runs, and `scripts/summarize_profile_trace.py` turns traces into a before and after
|
||||
table.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Texture uploads stalled the frame they were submitted on. ETC2 batches
|
||||
decoded on worker threads but were then resampled one upload at a time on
|
||||
the submitting thread, which at the default 4x upscale is sixteen times the
|
||||
decoded texels. Resampling now runs on the same worker pool, in two passes so
|
||||
mip level 0 still resolves before the mips built from it. In a 70k-part
|
||||
place the worst `vkQueueSubmit` fell from 167ms to 92ms.
|
||||
- Most ETC2 batches decoded on a single thread. Workers were created and
|
||||
joined per batch, so the parallel floor had to cover that cost and sat at a
|
||||
1024x1024 image; batches under it ran on the caller, which was 54% of all
|
||||
decode time in a 70k-part place. Decode workers are now a persistent pool,
|
||||
and the floor drops to a 128x128 image. Mean decode time in that place fell
|
||||
from 8.2ms to 4.7ms, and 11.8ms before both texture fixes.
|
||||
- On CPUs with a wide core-speed spread, Feral GameMode pinned the process to
|
||||
the few fastest cores, concentrating Roblox's worker pool onto them instead
|
||||
of spreading it. With `performance.gamemode: auto`, a request that narrows
|
||||
the CPU affinity is now released again, which releases the pin. Set
|
||||
`pin_cores=no` in `~/.config/gamemode.ini` to keep GameMode without the
|
||||
pinning, or `performance.gamemode: on` to accept it. See
|
||||
`docs/PERFORMANCE.md`.
|
||||
- With `show_place_name: false`, Discord no longer shows the experience
|
||||
thumbnail or its name on hover.
|
||||
- The host main thread no longer spins on the engine's message pump, which
|
||||
cost about half a core and 146,000 empty calls a second. It now rests 100 µs
|
||||
between polls: sleeping when the governor is `performance`, parking the
|
||||
core with TPAUSE on CPUs that have it, spinning otherwise. With GameMode
|
||||
setting the governor, process CPU in a 60k-part place fell from 216% to
|
||||
107% at the same 120 fps. `MOCKTAIL_ENGINE_PUMP_REST` forces a mode; see
|
||||
`docs/PERFORMANCE.md`.
|
||||
- ETC2 uploads with a `bufferRowLength` or `bufferImageHeight` larger than
|
||||
the image read the padded rows as packed data and decoded garbage.
|
||||
- ETC2 resampling created and joined worker threads on every batch. It now
|
||||
runs on the persistent decode pool.
|
||||
- A failed trace write left the profile writer thread waking every 250 ms
|
||||
for the rest of the session. It now exits.
|
||||
- The `--profile` trace gains a `pump` slice for the engine's main-thread
|
||||
step.
|
||||
- Texture uploads stalled the frame they were submitted on. ETC2 batches decoded on worker threads but were
|
||||
then resampled one upload at a time on the submitting thread, which at the default 4x upscale is sixteen
|
||||
times the decoded texels. Resampling now runs on the same worker pool, in two passes so mip level 0 still
|
||||
resolves before the mips built from it. In a 70k-part place the worst `vkQueueSubmit` fell from 167ms to
|
||||
92ms.
|
||||
- Most ETC2 batches decoded on a single thread. Workers were created and joined per batch, so the parallel
|
||||
floor had to cover that cost and sat at a 1024x1024 image; batches under it ran on the caller, which was 54%
|
||||
of all decode time in a 70k-part place. Decode workers are now a persistent pool, and the floor drops to a
|
||||
128x128 image. Mean decode time in that place fell from 8.2ms to 4.7ms, and 11.8ms before both texture
|
||||
fixes.
|
||||
- On CPUs with a wide core-speed spread, Feral GameMode pinned the process to the few fastest cores,
|
||||
concentrating Roblox's worker pool onto them instead of spreading it. With `performance.gamemode: auto`, a
|
||||
request that narrows the CPU affinity is now released again, which releases the pin. Set `pin_cores=no` in
|
||||
`~/.config/gamemode.ini` to keep GameMode without the pinning, or `performance.gamemode: on` to accept it.
|
||||
See `docs/PERFORMANCE.md`.
|
||||
- With `show_place_name: false`, Discord no longer shows the experience thumbnail or its name on hover.
|
||||
- The host main thread no longer spins on the engine's message pump, which cost about half a core and 146,000
|
||||
empty calls a second. It now rests 100 µs between polls: sleeping when the governor is `performance`,
|
||||
parking the core with TPAUSE on CPUs that have it, spinning otherwise. With GameMode setting the governor,
|
||||
process CPU in a 60k-part place fell from 216% to 107% at the same 120 fps. `MOCKTAIL_ENGINE_PUMP_REST`
|
||||
forces a mode; see `docs/PERFORMANCE.md`.
|
||||
- ETC2 uploads with a `bufferRowLength` or `bufferImageHeight` larger than the image read the padded rows as
|
||||
packed data and decoded garbage.
|
||||
- ETC2 resampling created and joined worker threads on every batch. It now runs on the persistent decode pool.
|
||||
- A failed trace write left the profile writer thread waking every 250 ms for the rest of the session. It now
|
||||
exits.
|
||||
- The `--profile` trace gains a `pump` slice for the engine's main-thread step.
|
||||
|
||||
## [0.2.0] - 2026-09-16
|
||||
|
||||
### Added
|
||||
|
||||
- FAQ covering Discord RPC, log locations, and VR, adapted from upstream.
|
||||
- `input.raw_mouse` in `config.yaml` sends mouse look deltas in the host's
|
||||
own units. Turn it on when first-person aiming feels too slow or too fast
|
||||
under fractional display scaling. Off by default.
|
||||
- Nightly AppImage builds, published as the `continuous` prerelease. They are
|
||||
untested; use a tagged release for normal play.
|
||||
- `input.raw_mouse` in `config.yaml` sends mouse look deltas in the host's own units. Turn it on when
|
||||
first-person aiming feels too slow or too fast under fractional display scaling. Off by default.
|
||||
- Nightly AppImage builds, published as the `continuous` prerelease. They are untested; use a tagged release
|
||||
for normal play.
|
||||
|
||||
### Changed
|
||||
|
||||
- Values in `fflags.json` now win over the performance preset instead of
|
||||
stopping the launch. Startup prints each key it kept.
|
||||
- Discord Rich Presence uses Nightcap's own Discord application, so it shows
|
||||
as "Playing Nightcap". Terms and privacy pages for it live on the
|
||||
project site.
|
||||
- Discord Rich Presence is on by default. Set
|
||||
`integrations.discord_rpc.enabled: false` to turn it off.
|
||||
- The AppImage build verifies its reduced dependency packages against digests
|
||||
taken at build time, rather than a digest list kept in the repository.
|
||||
- Values in `fflags.json` now win over the performance preset instead of stopping the launch. Startup prints
|
||||
each key it kept.
|
||||
- Discord Rich Presence uses Nightcap's own Discord application, so it shows as "Playing Nightcap". Terms and
|
||||
privacy pages for it live on the project site.
|
||||
- Discord Rich Presence is on by default. Set `integrations.discord_rpc.enabled: false` to turn it off.
|
||||
- The AppImage build verifies its reduced dependency packages against digests taken at build time, rather than
|
||||
a digest list kept in the repository.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Mouse look keeps responding after a long turn. The tracked pointer position
|
||||
could drift past the edge of the view, which swallowed every reversal until
|
||||
the mouse travelled all the way back.
|
||||
- Nightcap no longer refuses to start with `cannot lock appStorage`. It
|
||||
created its own credential directory using the process umask, then rejected
|
||||
that directory for being group writable. Systems with a permissive umask,
|
||||
such as `002`, failed on first run.
|
||||
- Mouse look keeps responding after a long turn. The tracked pointer position could drift past the edge of the
|
||||
view, which swallowed every reversal until the mouse travelled all the way back.
|
||||
- Nightcap no longer refuses to start with `cannot lock appStorage`. It created its own credential directory
|
||||
using the process umask, then rejected that directory for being group writable. Systems with a permissive
|
||||
umask, such as `002`, failed on first run.
|
||||
|
||||
## [0.1.0] - 2026-09-15
|
||||
|
||||
@@ -105,37 +277,35 @@ First Nightcap release, forked from komaruworld/mocktail.
|
||||
|
||||
### Added
|
||||
|
||||
- ETC2 and EAC texture emulation on Vulkan, so games that use compressed
|
||||
mobile textures render correctly on desktop GPUs. Decoding runs on worker
|
||||
threads to avoid stutter.
|
||||
- PNG texture overrides in `~/.config/mocktail/textures`, keyed by upload
|
||||
hash, with a dump mode to find the texture you want to replace.
|
||||
- Small textures are upscaled 4x by default. Set
|
||||
`MOCKTAIL_SMALL_TEXTURE_UPSCALE=1` to turn it off.
|
||||
- AppImage and signed Flatpak builds on every release tag. The Flatpak repo
|
||||
is published at https://coderdayton.github.io/nightcap/.
|
||||
- ETC2 and EAC texture emulation on Vulkan, so games that use compressed mobile textures render correctly on
|
||||
desktop GPUs. Decoding runs on worker threads to avoid stutter.
|
||||
- PNG texture overrides in `~/.config/mocktail/textures`, keyed by upload hash, with a dump mode to find the
|
||||
texture you want to replace.
|
||||
- Small textures are upscaled 4x by default. Set `MOCKTAIL_SMALL_TEXTURE_UPSCALE=1` to turn it off.
|
||||
- AppImage and signed Flatpak builds on every release tag. The Flatpak repo is published at
|
||||
https://coderdayton.github.io/nightcap/.
|
||||
- Roadmap in `docs/ROADMAP.md`.
|
||||
|
||||
### Changed
|
||||
|
||||
- Frames are presented as soon as they are ready instead of waiting in a
|
||||
queue, which lowers input latency.
|
||||
- Roblox now sees the real host RAM and display size instead of a low-end
|
||||
phone profile.
|
||||
- App ID is `io.github.CoderDayton.nightcap`, so Nightcap installs next to
|
||||
upstream Mocktail. The binary and config paths keep the `mocktail` name.
|
||||
- Frames are presented as soon as they are ready instead of waiting in a queue, which lowers input latency.
|
||||
- Roblox now sees the real host RAM and display size instead of a low-end phone profile.
|
||||
- App ID is `io.github.CoderDayton.nightcap`, so Nightcap installs next to upstream Mocktail. The binary and
|
||||
config paths keep the `mocktail` name.
|
||||
- New name, icon, and colors.
|
||||
- The desktop entry launches on Wayland and points at the installed binary.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Servers no longer kick with error 319 shortly after joining.
|
||||
- The FMOD output-device bridge is optional, so the updater no longer fails
|
||||
without it.
|
||||
- The AppImage build no longer fails on stale checksums for the slimmed
|
||||
Arch packages.
|
||||
- The FMOD output-device bridge is optional, so the updater no longer fails without it.
|
||||
- The AppImage build no longer fails on stale checksums for the slimmed Arch packages.
|
||||
|
||||
[Unreleased]: https://github.com/CoderDayton/nightcap/compare/v0.3.0...HEAD
|
||||
[Unreleased]: https://github.com/CoderDayton/nightcap/compare/v0.3.4...HEAD
|
||||
[0.3.4]: https://github.com/CoderDayton/nightcap/releases/tag/v0.3.4
|
||||
[0.3.3]: https://github.com/CoderDayton/nightcap/releases/tag/v0.3.3
|
||||
[0.3.2]: https://github.com/CoderDayton/nightcap/releases/tag/v0.3.2
|
||||
[0.3.1]: https://github.com/CoderDayton/nightcap/releases/tag/v0.3.1
|
||||
[0.3.0]: https://github.com/CoderDayton/nightcap/releases/tag/v0.3.0
|
||||
[0.2.0]: https://github.com/CoderDayton/nightcap/releases/tag/v0.2.0
|
||||
[0.1.0]: https://github.com/CoderDayton/nightcap/releases/tag/v0.1.0
|
||||
+43
-67
@@ -9,8 +9,8 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(Mocktail
|
||||
VERSION 1.0.4
|
||||
DESCRIPTION "Android x86-64 Roblox compatibility runtime for Linux"
|
||||
VERSION 0.3.4
|
||||
DESCRIPTION "Android Roblox compatibility runtime for Linux"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
@@ -249,6 +249,10 @@ mocktail_apply_compile_options(mocktail_updater)
|
||||
|
||||
add_library(mocktail_legacy_jnivm STATIC
|
||||
src/jnivm/jnivm.cc
|
||||
src/jnivm/jni_references.cc
|
||||
src/jnivm/jni_fields.cc
|
||||
src/jnivm/jni_strings.cc
|
||||
src/jnivm/jni_method_names.cc
|
||||
)
|
||||
add_library(Mocktail::LegacyJni ALIAS mocktail_legacy_jnivm)
|
||||
target_include_directories(mocktail_legacy_jnivm PUBLIC include)
|
||||
@@ -275,6 +279,7 @@ add_library(mocktail_runtime STATIC
|
||||
src/runtime/game_session_coordinator.cc
|
||||
src/runtime/graphics_launch_policy.cc
|
||||
src/runtime/http_client_policy.cc
|
||||
src/runtime/luau_codegen_switch.cc
|
||||
src/runtime/memory_limit.cc
|
||||
src/runtime/owned_pthread.cc
|
||||
src/runtime/performance_policy.cc
|
||||
@@ -285,12 +290,17 @@ add_library(mocktail_runtime STATIC
|
||||
src/runtime/roblox_capability_resolver.cc
|
||||
src/runtime/roblox_experience_launch_bridge.cc
|
||||
src/runtime/roblox_launch_uri.cc
|
||||
src/runtime/roblox_presence_resolver.cc
|
||||
src/runtime/roblox_game_session_native_adapter.cc
|
||||
src/runtime/roblox_web_view_bridge.cc
|
||||
src/runtime/roblox_permissions_bridge.cc
|
||||
src/runtime/roblox_account_bridge.cc
|
||||
src/runtime/roblox_message_bus_request_bridge.cc
|
||||
src/runtime/roblox_call_protocol_bridge.cc
|
||||
src/runtime/payload_update_preflight.cc
|
||||
src/runtime/process_launch_policy.cc
|
||||
src/runtime/process_diagnostics.cc
|
||||
src/runtime/asset_overlay_names.cc
|
||||
src/runtime/runtime_config.cc
|
||||
src/runtime/runtime_config_bootstrap.cc
|
||||
src/runtime/runtime_config_file.cc
|
||||
@@ -385,7 +395,8 @@ add_library(mocktail_webview_helper_policy STATIC
|
||||
src/webview/webview_helper_policy.cc
|
||||
)
|
||||
add_library(Mocktail::WebViewHelperPolicy ALIAS mocktail_webview_helper_policy)
|
||||
target_include_directories(mocktail_webview_helper_policy PUBLIC src)
|
||||
target_include_directories(mocktail_webview_helper_policy PUBLIC src
|
||||
PRIVATE include)
|
||||
target_link_libraries(mocktail_webview_helper_policy PUBLIC
|
||||
PkgConfig::WEBKITGTK6
|
||||
nlohmann_json::nlohmann_json
|
||||
@@ -472,7 +483,7 @@ target_link_libraries(mocktail_window PUBLIC
|
||||
Mocktail::SdlVulkanWsi
|
||||
SDL3::SDL3
|
||||
${CMAKE_DL_LIBS}
|
||||
PRIVATE Mocktail::Runtime Mocktail::GlesTextOverlay
|
||||
PRIVATE Mocktail::Runtime Mocktail::GlesTextOverlay Mocktail::GraphicsFoundation
|
||||
)
|
||||
|
||||
add_library(mocktail_roblox_output_device_runtime STATIC
|
||||
@@ -553,50 +564,6 @@ target_link_libraries(mocktail_bionic_abi_exports PRIVATE
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckIncludeFileCXX)
|
||||
include(CMakePushCheckState)
|
||||
|
||||
check_include_file_cxx(execinfo.h MOCKTAIL_HAVE_EXECINFO_H)
|
||||
if(NOT MOCKTAIL_HAVE_EXECINFO_H)
|
||||
message(FATAL_ERROR
|
||||
"execinfo.h is required for crash diagnostics; on musl install "
|
||||
"libexecinfo-devel"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(MOCKTAIL_EXECINFO_LINK_LIBRARY "")
|
||||
set(_mocktail_execinfo_link_probe [=[
|
||||
#include <execinfo.h>
|
||||
int main() {
|
||||
void* frames[1] = {};
|
||||
const int count = backtrace(frames, 1);
|
||||
return backtrace_symbols(frames, count) == nullptr;
|
||||
}
|
||||
]=])
|
||||
check_cxx_source_compiles(
|
||||
"${_mocktail_execinfo_link_probe}"
|
||||
MOCKTAIL_EXECINFO_IN_HOST_LIBC
|
||||
)
|
||||
if(NOT MOCKTAIL_EXECINFO_IN_HOST_LIBC)
|
||||
find_library(MOCKTAIL_EXECINFO_LIBRARY NAMES execinfo REQUIRED)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${MOCKTAIL_EXECINFO_LIBRARY}")
|
||||
check_cxx_source_compiles(
|
||||
"${_mocktail_execinfo_link_probe}"
|
||||
MOCKTAIL_EXECINFO_IN_EXTERNAL_LIBRARY
|
||||
)
|
||||
cmake_pop_check_state()
|
||||
if(NOT MOCKTAIL_EXECINFO_IN_EXTERNAL_LIBRARY)
|
||||
message(FATAL_ERROR
|
||||
"execinfo.h is available, but backtrace and backtrace_symbols cannot "
|
||||
"be linked"
|
||||
)
|
||||
endif()
|
||||
set(MOCKTAIL_EXECINFO_LINK_LIBRARY "${MOCKTAIL_EXECINFO_LIBRARY}")
|
||||
endif()
|
||||
unset(_mocktail_execinfo_link_probe)
|
||||
|
||||
add_library(mocktail_legacy_runtime STATIC
|
||||
src/legacy/legacy_runtime.cc
|
||||
src/runtime/roblox_text_input_jni_bridge.cc
|
||||
@@ -621,7 +588,6 @@ target_link_libraries(mocktail_legacy_runtime PRIVATE
|
||||
libc_shim
|
||||
mocktail_window
|
||||
mocktail_graphics_foundation
|
||||
${MOCKTAIL_EXECINFO_LINK_LIBRARY}
|
||||
)
|
||||
target_compile_definitions(mocktail_legacy_runtime PRIVATE
|
||||
"MOCKTAIL_DEFAULT_COMPATIBILITY_MANIFEST=\"${MOCKTAIL_DEFAULT_COMPATIBILITY_MANIFEST}\""
|
||||
@@ -650,6 +616,11 @@ target_link_options(mocktail PRIVATE
|
||||
)
|
||||
|
||||
# Native FreeBSD helper for Linuxulator's unsupported DF socket option.
|
||||
# The helper is x86-64 assembly; other host architectures have nothing to
|
||||
# assemble.
|
||||
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$")
|
||||
set(MOCKTAIL_BUILD_FREEBSD_SOCKET_HELPER OFF)
|
||||
endif()
|
||||
option(MOCKTAIL_BUILD_FREEBSD_SOCKET_HELPER
|
||||
"Build the native FreeBSD Linuxulator socket helper" ON)
|
||||
if(MOCKTAIL_BUILD_FREEBSD_SOCKET_HELPER)
|
||||
@@ -786,33 +757,39 @@ install(CODE "
|
||||
endif()
|
||||
")
|
||||
|
||||
set(MOCKTAIL_PACKAGE_NAMES mocktail mocktail-nightly nightcap nightcap-nightly)
|
||||
set(MOCKTAIL_PACKAGE_NAME "mocktail" CACHE STRING
|
||||
"Native package name"
|
||||
)
|
||||
set(MOCKTAIL_PACKAGE_VERSION "${PROJECT_VERSION}" CACHE STRING
|
||||
"Native package version"
|
||||
)
|
||||
set(MOCKTAIL_PACKAGE_VERSION_SUFFIX "" CACHE STRING
|
||||
"Native package version suffix"
|
||||
)
|
||||
if(NOT MOCKTAIL_PACKAGE_NAME STREQUAL "mocktail" AND
|
||||
NOT MOCKTAIL_PACKAGE_NAME STREQUAL "mocktail-nightly")
|
||||
if(NOT MOCKTAIL_PACKAGE_NAME IN_LIST MOCKTAIL_PACKAGE_NAMES)
|
||||
string(JOIN ", " MOCKTAIL_PACKAGE_NAMES_TEXT ${MOCKTAIL_PACKAGE_NAMES})
|
||||
message(FATAL_ERROR
|
||||
"MOCKTAIL_PACKAGE_NAME must be mocktail or mocktail-nightly")
|
||||
"MOCKTAIL_PACKAGE_NAME must be one of ${MOCKTAIL_PACKAGE_NAMES_TEXT}")
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_NAME "${MOCKTAIL_PACKAGE_NAME}")
|
||||
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}${MOCKTAIL_PACKAGE_VERSION_SUFFIX}")
|
||||
set(CPACK_PACKAGE_VENDOR "Mocktail Project")
|
||||
set(CPACK_PACKAGE_CONTACT "komaruworld <rtysus228@gmail.com>")
|
||||
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/komaruworld/mocktail")
|
||||
set(CPACK_PACKAGE_VERSION
|
||||
"${MOCKTAIL_PACKAGE_VERSION}${MOCKTAIL_PACKAGE_VERSION_SUFFIX}"
|
||||
)
|
||||
set(CPACK_PACKAGE_VENDOR "Nightcap")
|
||||
set(CPACK_PACKAGE_CONTACT "vii <coderdayton14@gmail.com>")
|
||||
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/CoderDayton/nightcap")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
|
||||
set(CPACK_PACKAGE_DESCRIPTION
|
||||
"Runs the Android x86-64 Roblox client on Linux."
|
||||
"Runs the Android Roblox client on Linux."
|
||||
)
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
|
||||
set(CPACK_STRIP_FILES TRUE)
|
||||
|
||||
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "komaruworld <rtysus228@gmail.com>")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "vii <coderdayton14@gmail.com>")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
|
||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
@@ -822,15 +799,14 @@ set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0")
|
||||
set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV ON)
|
||||
|
||||
if(MOCKTAIL_PACKAGE_NAME STREQUAL "mocktail-nightly")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONFLICTS "mocktail")
|
||||
set(CPACK_DEBIAN_PACKAGE_REPLACES "mocktail")
|
||||
set(CPACK_RPM_PACKAGE_CONFLICTS "mocktail")
|
||||
else()
|
||||
set(CPACK_DEBIAN_PACKAGE_CONFLICTS "mocktail-nightly")
|
||||
set(CPACK_DEBIAN_PACKAGE_REPLACES "mocktail-nightly")
|
||||
set(CPACK_RPM_PACKAGE_CONFLICTS "mocktail-nightly")
|
||||
endif()
|
||||
# Every variant installs the same /usr/bin/mocktail and /usr/share/mocktail,
|
||||
# so only one of them can be present at a time.
|
||||
set(MOCKTAIL_PACKAGE_SIBLINGS ${MOCKTAIL_PACKAGE_NAMES})
|
||||
list(REMOVE_ITEM MOCKTAIL_PACKAGE_SIBLINGS "${MOCKTAIL_PACKAGE_NAME}")
|
||||
string(JOIN ", " MOCKTAIL_PACKAGE_CONFLICTS ${MOCKTAIL_PACKAGE_SIBLINGS})
|
||||
set(CPACK_DEBIAN_PACKAGE_CONFLICTS "${MOCKTAIL_PACKAGE_CONFLICTS}")
|
||||
set(CPACK_DEBIAN_PACKAGE_REPLACES "${MOCKTAIL_PACKAGE_CONFLICTS}")
|
||||
set(CPACK_RPM_PACKAGE_CONFLICTS "${MOCKTAIL_PACKAGE_CONFLICTS}")
|
||||
include(CPack)
|
||||
|
||||
add_dependencies(mocktail all_stubs)
|
||||
|
||||
@@ -42,17 +42,28 @@ attach `latest.log`:
|
||||
|
||||
For native installs, a custom `$XDG_STATE_HOME` replaces `~/.local/state`.
|
||||
|
||||
## Can I run multiple Roblox instances?
|
||||
|
||||
No. Nightcap won't add multi-instance launching. It would mean working around
|
||||
Roblox's restrictions on running several clients. The [Roblox Terms of Use](https://en.help.roblox.com/hc/en-us/articles/115004647846-Roblox-Terms-of-Use)
|
||||
prohibit bypassing technical protections, and violating the terms can get your
|
||||
account suspended.
|
||||
|
||||
Bloxstrap brought the option back in [v2.9.0](https://github.com/bloxstraplabs/bloxstrap/releases/tag/v2.9.0)
|
||||
with a "use at your own risk" warning, then removed it in
|
||||
[v2.10.0](https://github.com/bloxstraplabs/bloxstrap/releases/tag/v2.10.0)
|
||||
after Roblox added measures against running multiple clients.
|
||||
|
||||
## Can I play in VR?
|
||||
|
||||
VR is experimental and lives on upstream's `vr` branch, which does not
|
||||
include the Nightcap changes. Install the
|
||||
Yes, as an experiment. VR lives on Nightcap's `vr` branch and is not in the
|
||||
releases yet. It works on Roblox builds 2998, 3092 and 3222. Install the
|
||||
[build dependencies](README.md#building), then switch to that branch and
|
||||
build:
|
||||
|
||||
```bash
|
||||
git remote add upstream https://github.com/komaruworld/mocktail.git
|
||||
git fetch upstream
|
||||
git switch -c vr upstream/vr
|
||||
git fetch origin
|
||||
git switch vr
|
||||
git submodule update --init --recursive
|
||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMOCKTAIL_ENABLE_VR=ON
|
||||
cmake --build build -j4
|
||||
@@ -61,5 +72,10 @@ cmake --build build -j4
|
||||
Start WiVRn or SteamVR/ALVR, connect your headset, then run:
|
||||
|
||||
```bash
|
||||
./build/mocktail -vr
|
||||
./build/mocktail --vr
|
||||
```
|
||||
|
||||
That branch's
|
||||
[README](https://github.com/CoderDayton/nightcap/blob/vr/README.md#experimental-vr)
|
||||
and [docs/VR.md](https://github.com/CoderDayton/nightcap/blob/vr/docs/VR.md)
|
||||
have the details, including how to try it without a headset.
|
||||
@@ -21,7 +21,7 @@ ANYLINUX_APPIMAGETOOL ?= appimagetool
|
||||
PREFIX ?= /usr
|
||||
FLATPAK_BUILD_DIR ?= build-flatpak
|
||||
FLATPAK_MANIFEST ?= packaging/flatpak/io.github.CoderDayton.nightcap.json
|
||||
FLATPAK_JOBS ?= 4
|
||||
FLATPAK_JOBS ?= 2
|
||||
|
||||
define build_native_runtime
|
||||
@git submodule update --init --recursive
|
||||
@@ -130,8 +130,8 @@ auto-run: ## Build/run loop with crash summaries
|
||||
run-gles: build ## Run strict system EGL/OpenGL ES 3 without Vulkan fallback
|
||||
@$(BINARY) --graphics opengl
|
||||
|
||||
run-angle: ## Run with ANGLE/Vulkan compatibility backend
|
||||
@MOCKTAIL_GRAPHICS_BACKEND=angle-vulkan ./scripts/run_sober.sh
|
||||
run-angle: build ## Run with ANGLE/Vulkan compatibility backend
|
||||
@$(BINARY) --graphics angle-vulkan
|
||||
|
||||
update-roblox: ## Validate and import the current x86_64 Roblox bundle cached by Sober
|
||||
@./scripts/update_roblox_payload.sh
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
<!-- Modified by vii from komaruworld/mocktail. See "About this fork" below. -->
|
||||
# Nightcap
|
||||
<div align="center">
|
||||
<img src="https://raw.githubusercontent.com/CoderDayton/nightcap/main/packaging/io.github.CoderDayton.nightcap.svg" alt="Nightcap logo" width="128">
|
||||
<h1 style="margin-top: 5px;">
|
||||
Nightcap
|
||||
<br>
|
||||
<a href="https://github.com/CoderDayton/nightcap/actions/workflows/ci.yml"><img src="https://github.com/CoderDayton/nightcap/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
||||
<a href="https://github.com/CoderDayton/nightcap/stargazers"><img src="https://img.shields.io/github/stars/CoderDayton/nightcap?style=flat&logo=github" alt="Stars"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License"></a>
|
||||
<a href="https://discord.gg/DbAUG9hBFU"><img alt="Discord" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdiscord.com%2Fapi%2Fv10%2Finvites%2FDbAUG9hBFU%3Fwith_counts%3Dtrue&query=%24.approximate_member_count&label=Discord&logo=discord&logoColor=white&color=5865F2&suffix=%20members"></a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
[](https://github.com/CoderDayton/nightcap/actions/workflows/ci.yml)
|
||||
[](https://github.com/CoderDayton/nightcap/stargazers)
|
||||
[](LICENSE)
|
||||
|
||||
Nightcap is Mocktail, tuned for playing on a real PC. It runs the Android
|
||||
`x86_64` Roblox client on Linux, including a Linux userspace hosted by
|
||||
FreeBSD's Linuxulator. It provides the Android ABI and JNI pieces the client
|
||||
expects, then connects them to SDL3 and Vulkan or OpenGL on the Linux side.
|
||||
Nightcap is Roblox on Linux, tuned for desktop play. It is a Mocktail fork
|
||||
that keeps up with Roblox updates, with extra bug fixes, custom assets and
|
||||
more. It runs the Android `x86_64` Roblox client on Linux, including a Linux
|
||||
userspace hosted by FreeBSD's Linuxulator. It provides the Android ABI and JNI
|
||||
pieces the client expects, then connects them to SDL3 and Vulkan or OpenGL on
|
||||
the Linux side.
|
||||
|
||||
Nightcap is an independent community project. It is not affiliated with Roblox
|
||||
Corporation or VinegarHQ and does not distribute the Roblox client.
|
||||
@@ -21,23 +29,25 @@ with extra fixes for playing on a PC. The program and config paths keep the
|
||||
`io.github.CoderDayton.nightcap`, so Nightcap and upstream can be installed
|
||||
side by side.
|
||||
|
||||
- **Lower input lag.** Frames are shown as soon as they are ready instead of
|
||||
waiting in a queue.
|
||||
- **Sharper textures.** Small textures are upscaled 4x by default, and you
|
||||
can replace any texture with your own PNG in `~/.config/mocktail/textures`.
|
||||
A ready-made crosshair is in [`textures/`](textures/README.md). Set
|
||||
`MOCKTAIL_SMALL_TEXTURE_UPSCALE=1` to turn the upscale off.
|
||||
- **ETC2 textures on any GPU.** Games that use compressed mobile textures now
|
||||
render correctly on desktop GPUs, without stutter.
|
||||
- **No more error 319 kicks.** Servers no longer drop you shortly after
|
||||
joining.
|
||||
- **Correct device info.** Roblox sees your real RAM and screen size.
|
||||
- **Better desktop launcher.** Runs on Wayland and always finds the installed
|
||||
binary.
|
||||
- **Keeps up with Roblox.** New Roblox versions work soon after they come out.
|
||||
- **Plays more games.** Nightcap answers a server check that some experiences
|
||||
use, so you can join and stay in those too.
|
||||
- **Voice chat that keeps working.** Your microphone still works after a
|
||||
Roblox update.
|
||||
- **Logging in works.** Verification checks and captchas finish instead of
|
||||
hanging.
|
||||
- **The current Roblox look.** The new home screen and side menu, like on
|
||||
Windows.
|
||||
- **Your own cursors, fonts and skies.** Drop files in
|
||||
`~/.local/share/mocktail/asset_overlay` and Nightcap uses them. The layout
|
||||
matches Sober's `asset_overlay` folder.
|
||||
- **Smoother mouse and a cooler PC.** Optional raw mouse input, and less CPU
|
||||
use while idle.
|
||||
|
||||
Everything else works the same as upstream. See the
|
||||
[roadmap](docs/ROADMAP.md) for what is coming next, the
|
||||
[changelog](CHANGELOG.md) for what each release changed,
|
||||
Everything else works the same as upstream. See
|
||||
[`textures/`](textures/README.md) for custom textures, a ready-made crosshair
|
||||
and the asset overlay folder, the [roadmap](docs/ROADMAP.md) for what is
|
||||
coming next, the [changelog](CHANGELOG.md) for what each release changed,
|
||||
[performance](docs/PERFORMANCE.md) for CPU load, heat and the knobs that change
|
||||
them, and the [FAQ](FAQ.md) for Discord RPC, logs, and VR.
|
||||
|
||||
@@ -61,10 +71,33 @@ chmod +x Nightcap-x86_64.AppImage
|
||||
./Nightcap-x86_64.AppImage
|
||||
```
|
||||
|
||||
Or build and install it from source using the steps under
|
||||
[Building](#building). There are no AUR, DEB, or RPM packages of Nightcap.
|
||||
Upstream ships those for unmodified Mocktail, see
|
||||
[komaruworld/mocktail](https://github.com/komaruworld/mocktail#readme).
|
||||
## Distribution packages
|
||||
|
||||
Each release also carries a DEB, an RPM, and a pacman package, with a
|
||||
`.sha256` beside every file on the
|
||||
[releases page](https://github.com/CoderDayton/nightcap/releases/latest):
|
||||
|
||||
```bash
|
||||
sudo apt install ./nightcap_<version>_amd64.deb
|
||||
sudo dnf install ./nightcap-<version>-1.x86_64.rpm
|
||||
sudo pacman -U nightcap-<version>-1-x86_64.pkg.tar.zst
|
||||
```
|
||||
|
||||
They install `/usr/bin/mocktail`, so they conflict with upstream's `mocktail`
|
||||
package.
|
||||
|
||||
On Arch Linux, [`nightcap-git`](https://aur.archlinux.org/packages/nightcap-git)
|
||||
is on the AUR. It builds the current `main` branch and is maintained by
|
||||
[@dim-ghub](https://github.com/dim-ghub):
|
||||
|
||||
```bash
|
||||
yay -S nightcap-git
|
||||
```
|
||||
|
||||
Nightcap is in no other distribution repository.
|
||||
|
||||
Or build and install from source using the steps under
|
||||
[Building](#building).
|
||||
|
||||
## How it works
|
||||
|
||||
@@ -76,6 +109,12 @@ The APK is checked before any native code is loaded. It is downloaded on first
|
||||
launch and is not bundled with Nightcap. The last working copy is kept in case
|
||||
an update fails.
|
||||
|
||||
A leftover `.previous_good-recovery.json` in the payload store marks pending
|
||||
recovery after a publication or restoration failure and blocks further payload
|
||||
publication and garbage collection. Check `current.json` and `previous_good.json`
|
||||
against the saved recovery state and fix the underlying problem before manually
|
||||
removing the marker.
|
||||
|
||||
<details>
|
||||
<summary>Screenshots</summary>
|
||||
|
||||
@@ -83,8 +122,6 @@ an update fails.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
## FFlag overrides
|
||||
@@ -96,6 +133,14 @@ PC profiles use the legacy Charts page by default to avoid the blank screen
|
||||
caused by `Color3` errors in the newer SDUI page. An explicit
|
||||
`FFlagLuaAppChartsAppPage` override takes precedence over this default.
|
||||
|
||||
PC profiles also set `FIntFlyoutTestVariantRollout12` to `2`, which shows the
|
||||
desktop side panel menu. An explicit override takes precedence.
|
||||
|
||||
PC profiles compile the app's menus to native code with
|
||||
`FFlagDebugLuauCodegenAll`, and turn it off while you are in a game. Setting
|
||||
it yourself turns the switching off and your value applies everywhere. See
|
||||
[docs/PERFORMANCE.md](docs/PERFORMANCE.md#native-code-in-the-menus).
|
||||
|
||||
```json
|
||||
{
|
||||
"FFlagExample": "True",
|
||||
@@ -116,8 +161,9 @@ Linux `x86_64` is supported. Experimental FreeBSD 15.1 Linuxulator support has
|
||||
been tested with an `x86_64` Fedora 44 userspace. On FreeBSD, Nightcap runs
|
||||
inside Linuxulator; it is not a native FreeBSD binary. Building requires CMake
|
||||
3.20+, Git, pkg-config, LLD, binutils, a C++17 compiler, SDL 3.4+, SDL3_ttf,
|
||||
Vulkan, EGL, libplacebo, fontconfig, libcurl, OpenSSL, libelf, libyaml, minizip,
|
||||
Capstone 5, utf8proc, nlohmann/json, GTK4, libadwaita 1.6+, and WebKitGTK 6.0.
|
||||
Vulkan, EGL, libplacebo, fontconfig, libcurl, OpenSSL, libelf, libyaml, libpng,
|
||||
minizip, Capstone 5, utf8proc, nlohmann/json, GTK4, libadwaita 1.6+, and
|
||||
WebKitGTK 6.0.
|
||||
|
||||
See the [FreeBSD Guide](packaging/freebsd/README.md) for setup and launch instructions.
|
||||
|
||||
@@ -128,7 +174,7 @@ See the [FreeBSD Guide](packaging/freebsd/README.md) for setup and launch instru
|
||||
sudo apt update
|
||||
sudo apt install build-essential cmake git ninja-build pkg-config lld \
|
||||
libsdl3-dev libsdl3-ttf-dev libcurl4-openssl-dev libssl-dev \
|
||||
nlohmann-json3-dev libyaml-dev libelf-dev libminizip-dev \
|
||||
nlohmann-json3-dev libyaml-dev libpng-dev libelf-dev libminizip-dev \
|
||||
libcapstone-dev libgtk-4-dev libadwaita-1-dev libwebkitgtk-6.0-dev \
|
||||
libutf8proc-dev libfontconfig1-dev libegl-dev libvulkan-dev \
|
||||
libplacebo-dev zlib1g-dev
|
||||
@@ -140,7 +186,7 @@ sudo apt install build-essential cmake git ninja-build pkg-config lld \
|
||||
|
||||
```bash
|
||||
sudo pacman -S --needed base-devel cmake git ninja pkgconf lld sdl3 sdl3_ttf \
|
||||
curl openssl nlohmann-json libyaml libelf minizip capstone gtk4 \
|
||||
curl openssl nlohmann-json libyaml libpng libelf minizip capstone gtk4 \
|
||||
libadwaita webkitgtk-6.0 libutf8proc fontconfig libglvnd \
|
||||
libplacebo vulkan-headers vulkan-icd-loader zlib
|
||||
```
|
||||
@@ -152,7 +198,8 @@ sudo pacman -S --needed base-devel cmake git ninja pkgconf lld sdl3 sdl3_ttf \
|
||||
```bash
|
||||
sudo dnf install gcc-c++ cmake git ninja-build pkgconf-pkg-config lld \
|
||||
SDL3-devel SDL3_ttf-devel libcurl-devel openssl-devel \
|
||||
nlohmann-json-devel libyaml-devel elfutils-libelf-devel minizip-ng-compat-devel \
|
||||
nlohmann-json-devel libyaml-devel libpng-devel elfutils-libelf-devel \
|
||||
minizip-ng-compat-devel \
|
||||
capstone-devel gtk4-devel libadwaita-devel webkitgtk6.0-devel \
|
||||
utf8proc-devel fontconfig-devel libglvnd-devel vulkan-headers \
|
||||
vulkan-loader-devel libplacebo-devel zlib-ng-compat-devel
|
||||
@@ -176,6 +223,11 @@ Use `sudo make install` instead to install system-wide under `/usr`. To make
|
||||
Roblox website links open the build tree copy without installing, run
|
||||
`make register-url-handler`.
|
||||
|
||||
To build and install the Flatpak from source, install `flatpak-builder` and run
|
||||
`make flatpak`. It builds with 2 parallel jobs to keep memory use low. Pass
|
||||
`FLATPAK_JOBS=N` to `make flatpak`, or set `MOCKTAIL_FLATPAK_JOBS=N` for
|
||||
`scripts/build_flatpak.sh`, to change that.
|
||||
|
||||
To run the same checks as CI before each commit and push, install
|
||||
[lefthook](https://github.com/evilmartians/lefthook) and run once:
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 620 KiB After Width: | Height: | Size: 2.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1009 KiB |
@@ -4,6 +4,7 @@
|
||||
{
|
||||
"version_name": "2.721.1108",
|
||||
"version_code": 2350,
|
||||
"abi": "x86_64",
|
||||
"elf_build_id": "50e1b0abd123350e794226062fe3a1ef360c5f0d",
|
||||
"status": "legacy-researched",
|
||||
"default_allowed": false,
|
||||
@@ -15,6 +16,7 @@
|
||||
{
|
||||
"version_name": "2.725.1142",
|
||||
"version_code": 2546,
|
||||
"abi": "x86_64",
|
||||
"elf_build_id": "d0cb1fa0deb3d9161b4cd77530cbcd2e50de3a21",
|
||||
"status": "supported",
|
||||
"default_allowed": true,
|
||||
@@ -35,6 +37,7 @@
|
||||
{
|
||||
"version_name": "2.727.1199",
|
||||
"version_code": 2628,
|
||||
"abi": "x86_64",
|
||||
"elf_build_id": "1686400865ae0e408cd7bd67de7a439625c6fd13",
|
||||
"status": "supported",
|
||||
"default_allowed": true,
|
||||
@@ -46,6 +49,7 @@
|
||||
{
|
||||
"version_name": "2.734.917",
|
||||
"version_code": 2908,
|
||||
"abi": "x86_64",
|
||||
"elf_build_id": "63c5109637b7d7b2bdb8ed8f858023ff5ef49326",
|
||||
"status": "supported",
|
||||
"default_allowed": true,
|
||||
@@ -66,6 +70,19 @@
|
||||
{
|
||||
"version_name": "2.736.1408",
|
||||
"version_code": 2998,
|
||||
"abi": "arm64-v8a",
|
||||
"elf_build_id": "ed2b035768b1513561d0e6ea7f9bbec35b0e60e5",
|
||||
"status": "supported",
|
||||
"default_allowed": true,
|
||||
"allow_legacy_binary_patches": false,
|
||||
"allow_host_abi_bridges": true,
|
||||
"allow_host_constructor_replay": true,
|
||||
"reason": "AArch64 arm64-v8a payload of the same 2.736.1408 release as the verified x86-64 profile; allocator, constructor replay, and pre-JNI bootstrap RVAs were derived by cross-architecture semantic matching."
|
||||
},
|
||||
{
|
||||
"version_name": "2.736.1408",
|
||||
"version_code": 2998,
|
||||
"abi": "x86_64",
|
||||
"elf_build_id": "ade08266c67aee88ec9c1d00902150e1684dad3a",
|
||||
"status": "supported",
|
||||
"default_allowed": true,
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"mode": "vendored-patched-snapshot",
|
||||
"url": "https://github.com/minecraft-linux/mcpelauncher-linker.git",
|
||||
"upstream_commit": "1ac3ea6c1cf4f73a84d73f0bff510fba94a7d0f2",
|
||||
"vendor_tree": "fca44d85e3773c135ccfc603b14abdf6aeb8efd1",
|
||||
"vendor_tree": "0637221e48f382ec8d0bc701385f4b10bcd07a65",
|
||||
"patch": "third_party/patches/mcpelauncher-linker.patch",
|
||||
"nested_sources": {
|
||||
"android_bionic": {
|
||||
|
||||
+33
-2
@@ -44,16 +44,36 @@ Each slice is named after the call it times, on the thread that made it.
|
||||
| `present` | `host present`: the host driver's present, nested inside the slice above | |
|
||||
| `wait` | `vkAcquireNextImageKHR`, `vkAcquireNextImage2KHR`, `vkWaitForFences`, `vkWaitSemaphores`, `vkWaitSemaphoresKHR`, `vkQueueWaitIdle`, `vkDeviceWaitIdle` | |
|
||||
| `submit` | `vkQueueSubmit`, `vkQueueSubmit2`, `vkQueueSubmit2KHR` | `submits` |
|
||||
| `texture` | `etc2 decode`: CPU decode of ETC2 textures before a submit | `uploads`, `compressed_bytes`, `decoded_bytes` |
|
||||
| `texture` | `etc2 decode`: CPU decode of ETC2 textures. On a device with a timeline semaphore this runs on the decode dispatcher, not the submitting thread | `uploads`, `compressed_bytes`, `decoded_bytes` |
|
||||
| `texture` | `etc2 gather`: the part of an asynchronous upload that stays on the submitting thread. Absent when the decode ran inline | `uploads`, `compressed_bytes`, `decoded_bytes`, `ticket` |
|
||||
| `texture` | `etc2 staging create`: creating a staging block for ETC2 uploads, when no block has room left | `bytes` |
|
||||
| `texture` | `etc2 staging destroy`: destroying empty staging blocks beyond the four kept idle | `buffers` |
|
||||
| `texture` | `etc2 release wait`: a command buffer reset waiting for its uploads' decode. Only waits of 0.1 ms or more are recorded | `ticket` |
|
||||
| `memory` | `vkAllocateMemory` | `bytes`, `type` (memory type index), `result` |
|
||||
| `memory` | `vkFreeMemory`, `vkUnmapMemory`: both include waiting for ETC2 decodes that still read that memory | |
|
||||
| `memory` | `vkMapMemory`, `vkCreateImage`, `vkDestroyImage` | |
|
||||
| `pipeline` | `vkCreateGraphicsPipelines`, `vkCreateComputePipelines` | `count`, `cache` (1 when a pipeline cache was passed), `result` |
|
||||
| `pipeline` | `vkCreateShaderModule` | `bytes`, `result` |
|
||||
| `pipeline` | `vkCreatePipelineCache` | `initial_bytes`, `result` |
|
||||
| `pump` | `nativeCallMessagesFromMainThread`: the engine's main-thread step, on the host main thread. Only calls of 20 µs or more are recorded; the empty polls between them are not. | |
|
||||
| `pump` | `nativeCallMessagesFromMainThread`: the engine's main-thread step, on the host main thread. Only calls of 20 µs or more are recorded; the empty polls between them are not. | `cpu_us`: CPU time the main thread used during the call. Far below the slice's duration means the step spent it waiting |
|
||||
|
||||
The `frame interval (ms)` counter is the time between successive adapter
|
||||
presents. `vkQueuePresentKHR` time minus `host present` time is the adapter's
|
||||
own cost per frame.
|
||||
|
||||
Two more counters cover the same interval. `present thread cpu (ms)` is the
|
||||
CPU time the thread that presents used in it, and is absent for a frame
|
||||
presented from a different thread than the one before. `process cpu (ms)` is
|
||||
the CPU time of every thread together, so dividing it by the frame interval
|
||||
gives the number of cores busy. A long frame with little present-thread CPU
|
||||
was spent waiting.
|
||||
|
||||
`emulated texture (MB)` is the VRAM held by the decoded images that stand in
|
||||
for live ETC2/EAC textures, over every mip level and layer, upscaled where
|
||||
small-texture upscale applies. `compressed texture (MB)` is the size the same
|
||||
textures would take as ETC2/EAC. Both change only when such an image is
|
||||
created or destroyed. `summarize_profile_trace.py` prints each one's peak.
|
||||
|
||||
## The benchmark runs
|
||||
|
||||
Run every scenario before and after the change, on the same build type
|
||||
@@ -61,6 +81,17 @@ Run every scenario before and after the change, on the same build type
|
||||
Record `graphics.frame_rate_limit` and `graphics.vsync` in the pull request,
|
||||
because a frame cap hides frame time gains.
|
||||
|
||||
Record `~/.config/gamemode.ini` too, and do not change it between the before
|
||||
and after runs. `desiredgov` there decides the CPU governor for the whole
|
||||
session and therefore which engine pump mode is chosen, which moves process
|
||||
CPU by more than most changes under test. See
|
||||
[PERFORMANCE.md](PERFORMANCE.md).
|
||||
|
||||
Frame interval p99 varies by 2 ms or more between identical runs, so a
|
||||
difference that size is not a result. Three runs per scenario is the minimum
|
||||
for any frame-time claim; slice totals for a specific subsystem are far less
|
||||
noisy and can be read from fewer.
|
||||
|
||||
| Scenario | How to start | What to do | What it shows |
|
||||
| --- | --- | --- | --- |
|
||||
| Home screen, cold | `mocktail --profile home-cold.json` with an empty shader cache (below) | Wait 30 s on the home screen, exit | First-load stutter: `pipeline` and `texture` slices |
|
||||
|
||||
+90
-4
@@ -27,20 +27,48 @@ request. If GameMode narrowed it, Nightcap ends the request and prints:
|
||||
```
|
||||
|
||||
The trade is that GameMode's governor and priority boost go with it. To keep
|
||||
those and lose only the pinning, turn pinning off for every game on the host:
|
||||
those and lose only the pinning, turn pinning off for every game on the host.
|
||||
|
||||
These are the settings to run with:
|
||||
|
||||
```ini
|
||||
# ~/.config/gamemode.ini
|
||||
[general]
|
||||
desiredgov=performance
|
||||
|
||||
[cpu]
|
||||
pin_cores=no
|
||||
park_cores=no
|
||||
```
|
||||
|
||||
`desiredgov` is the one to check first. The packaged default in
|
||||
`/usr/share/gamemode/gamemode.ini` is already `performance`, but a value in
|
||||
your own file replaces it, and `desiredgov=powersave` there means GameMode
|
||||
clocks the CPU **down** for the whole session while still reporting
|
||||
`[gamemode] performance request active`. The symptoms are a low CPU clock
|
||||
under load, a GPU that never leaves its lower SM clocks, and the engine pump
|
||||
falling back to `tpause` — which costs about 70% of a core instead of 3%,
|
||||
because `sleep` is only chosen when the governor reads `performance`. On one
|
||||
13900K host, correcting `powersave` to `performance` took the process from
|
||||
177% CPU to 42% and the package from 70°C to 53-63°C, at the same frame rate.
|
||||
|
||||
GameMode reads `$XDG_CONFIG_HOME`, `/usr/share/gamemode` and `/etc`, in that
|
||||
order. It does not read anything under Nightcap's own config directory, so this
|
||||
file has to live in one of those three places. The daemon reads it when it
|
||||
starts, so restart it after editing: `systemctl --user restart gamemoded`.
|
||||
|
||||
Restarting the daemon drops the session of any game already running; relaunch
|
||||
the game for new settings to apply to it.
|
||||
|
||||
`gamemoded` is D-Bus activated through
|
||||
`com.feralinteractive.GameMode.service`, so `systemctl --user stop gamemoded`
|
||||
does not hold — the next client request starts it again within seconds. To
|
||||
measure with GameMode genuinely off, mask it:
|
||||
|
||||
```bash
|
||||
systemctl --user mask gamemoded # and --unmask afterwards
|
||||
```
|
||||
|
||||
The governor switch runs through polkit. Debian and Ubuntu only allow it for
|
||||
members of the `gamemode` group; without that, the daemon's journal shows
|
||||
`cpugovctl set performance: Not authorized` and the governor stays put while
|
||||
@@ -59,9 +87,20 @@ to the affinity. `off` never contacts the daemon.
|
||||
To see which CPUs the process may use:
|
||||
|
||||
```bash
|
||||
taskset -pc $(pgrep -x mocktail)
|
||||
pid=$(pgrep -x Main)
|
||||
for t in /proc/$pid/task/*; do taskset -pc "${t##*/}"; done
|
||||
```
|
||||
|
||||
Two traps here. The engine process reports its name as `Main`, not
|
||||
`mocktail`; `pgrep -x mocktail` finds only the launcher, which sits near 0%
|
||||
CPU and tells you nothing. And `taskset -p` reads one thread, not the whole
|
||||
process, so a single call reports the main thread's mask and says nothing
|
||||
about the workers — which is where the game's load actually is.
|
||||
|
||||
For the same reason, `ps -L -o psr=` shows which core each thread is running
|
||||
on right now, not which cores it is allowed on. On a hybrid CPU the scheduler
|
||||
preferring P-cores for runnable work is normal and is not a mask.
|
||||
|
||||
## The main-thread pump
|
||||
|
||||
Roblox posts its per-frame main-thread step at a time of its own choosing,
|
||||
@@ -90,14 +129,30 @@ runs cooler for a few frames per second less; measure before keeping it.
|
||||
|
||||
## Small texture upscaling
|
||||
|
||||
`MOCKTAIL_SMALL_TEXTURE_UPSCALE` (default `4`) redraws ETC2 textures of 64px or
|
||||
`MOCKTAIL_SMALL_TEXTURE_UPSCALE` (default `4`) stores ETC2 textures of 64px or
|
||||
smaller at N times their width and height. At the default that is 16 times the
|
||||
pixels per affected texture.
|
||||
|
||||
Upscaling alone adds no detail. Each original pixel becomes an N×N block of the
|
||||
same colour, and the GPU's filtering already blends a small texture that much
|
||||
when it draws it. The extra size only shows when a replacement PNG in
|
||||
`~/.config/mocktail/textures` has more detail than the original.
|
||||
|
||||
The cost lands in two places. Decoding and resampling is CPU work on up to 8
|
||||
threads while textures load, which shows up as a burst rather than a steady
|
||||
load. The enlarged textures then stay in GPU memory for the session and cost
|
||||
extra sampling bandwidth on every frame that uses them.
|
||||
extra sampling bandwidth on every frame that uses them. In Blade Ball the
|
||||
memory share is small: decoded textures came to 5.1 times their ETC2 size both
|
||||
with the default and with upscaling off. The `emulated texture (MB)` and
|
||||
`compressed texture (MB)` counters in a `--profile` trace give the figures for
|
||||
any game.
|
||||
|
||||
That decode does not run on the thread that submits the frame. On a device
|
||||
with a timeline semaphore, uploads decode on a background dispatcher and the
|
||||
submit carries a semaphore wait, so the GPU waits for the texture instead of
|
||||
the render thread. In the trace this is the `etc2 decode` slice on its own
|
||||
thread, with only a negligible `etc2 gather` left on the submitting one. A
|
||||
device without that feature decodes inline as before.
|
||||
|
||||
Set it to `1` to turn upscaling off:
|
||||
|
||||
@@ -105,6 +160,37 @@ Set it to `1` to turn upscaling off:
|
||||
MOCKTAIL_SMALL_TEXTURE_UPSCALE=1 mocktail
|
||||
```
|
||||
|
||||
## Native code in the menus
|
||||
|
||||
The home screen and avatar editor run Roblox's Lua app in the Luau interpreter,
|
||||
and its long frames come from that thread. PC profiles set
|
||||
`FFlagDebugLuauCodegenAll`, which compiles every script to native code. That
|
||||
makes the menus' Lua about 2.5 times cheaper for about 56 MB of compiled code.
|
||||
|
||||
In a game the same flag compiles every game script too: Blade Ball grew from 7
|
||||
MB to about 300 MB and hit Roblox's native code limit, which shows warnings in
|
||||
F9. So Nightcap turns the flag off when a game starts joining and back on when
|
||||
you return to the menus. Roblox reads the flag each time it compiles a script,
|
||||
and a game's compiled code is freed when you leave it. Games run with Roblox's
|
||||
own per-script choice, the same as without the flag.
|
||||
|
||||
The log shows each switch:
|
||||
|
||||
```text
|
||||
[luau-codegen] menus-only switch at +0x<offset in libroblox.so>
|
||||
[luau-codegen] native code for all scripts off
|
||||
[luau-codegen] native code for all scripts on
|
||||
```
|
||||
|
||||
Setting `FFlagDebugLuauCodegenAll` in `fflags.json` turns the switching off
|
||||
and your value applies everywhere. To keep the interpreter in the menus too:
|
||||
|
||||
```json
|
||||
{
|
||||
"FFlagDebugLuauCodegenAll": false
|
||||
}
|
||||
```
|
||||
|
||||
## Frame rate and present mode
|
||||
|
||||
`graphics.frame_rate_limit` (default `-1`) leaves Roblox's own in-game
|
||||
|
||||
+22
-45
@@ -16,75 +16,52 @@ Goal: a small GTK4 settings window, reachable from the app menu and from a
|
||||
- Input tab: the `input.raw_mouse` toggle and controller options.
|
||||
- Advanced tab: FFlag overrides with a plain text editor for `fflags.json`.
|
||||
- Discord tab: every field in the `discord_rpc` block, so a friend can see
|
||||
what you are playing and you can switch it all off in one click.
|
||||
what you are playing and you can switch it all off in one click.
|
||||
- Changes apply on next launch. A restart button restarts Nightcap.
|
||||
|
||||
Done when every option in `config/mocktail.example.yaml` that a player would
|
||||
touch can be set without a text editor.
|
||||
|
||||
## 2. Controller button glyphs
|
||||
|
||||
Upstream added Xbox and PlayStation gamepad support through SDL. Controllers
|
||||
already hot-plug and release their held inputs when unplugged. One rough edge
|
||||
is left.
|
||||
|
||||
- Correct button glyphs for the connected pad. `SDL_GetGamepadType` is only
|
||||
read for Xbox and PlayStation pads, so a Switch Pro, a GameCube pad, or any
|
||||
generic pad SDL reports as `SDL_GAMEPAD_TYPE_STANDARD` reaches Roblox as
|
||||
type 0 and draws generic glyphs. `SDL_GetRealGamepadType`, and the vendor
|
||||
and product IDs, are available and unused.
|
||||
|
||||
Done when a plugged-in pad shows its own buttons.
|
||||
|
||||
## 3. First-load stutter
|
||||
|
||||
The `--profile` trace now shows shader compiles and pipeline creation, so
|
||||
the stutter on first entering an experience can be measured.
|
||||
|
||||
- Cut the stutter the trace shows, and prove it with a before and after
|
||||
trace per [BENCHMARKING.md](BENCHMARKING.md).
|
||||
|
||||
Done when entering a fresh experience no longer drops frames on shader
|
||||
compiles.
|
||||
|
||||
## Shipped
|
||||
|
||||
- Lower input latency: frames are presented as soon as they are ready.
|
||||
- Controllers hot-plug without a restart, and a pad that is unplugged mid-game
|
||||
releases its held buttons and sticks instead of leaving them stuck.
|
||||
releases its held buttons and sticks instead of leaving them stuck.
|
||||
- Mouse look keeps responding after a long turn, instead of going dead until
|
||||
the pointer travels back from past the screen edge.
|
||||
the pointer travels back from past the screen edge.
|
||||
- Optional raw mouse input: `input.raw_mouse` in `config.yaml` sends look
|
||||
deltas in host units, so fractional display scaling no longer changes
|
||||
first-person sensitivity.
|
||||
deltas in host units, so fractional display scaling no longer changes
|
||||
first-person sensitivity.
|
||||
- Small textures upscaled 4x by default, with PNG overrides in
|
||||
`~/.config/mocktail/textures`.
|
||||
`~/.config/mocktail/textures`.
|
||||
- ETC2 textures decoded on desktop GPUs without stutter.
|
||||
- No more error 319 kicks after joining a server.
|
||||
- Roblox sees the real host RAM and screen size.
|
||||
- Desktop launcher that works on Wayland and finds the installed binary.
|
||||
- Discord Rich Presence on by default, with the experience name, creator,
|
||||
elapsed time, the experience icon with a Roblox badge, and a join button
|
||||
when the server is public. See the [FAQ](../FAQ.md) to switch it off.
|
||||
elapsed time, the experience icon with a Roblox badge, and a join button
|
||||
when the server is public. See the [FAQ](../FAQ.md) to switch it off.
|
||||
- Custom Discord presence: title, details, state, and large and small icons
|
||||
from `config.yaml`, with `{place_name}`, `{place_icon}`, and
|
||||
`{creator_name}` placeholders.
|
||||
from `config.yaml`, with `{place_name}`, `{place_icon}`, and
|
||||
`{creator_name}` placeholders.
|
||||
- `--profile` writes a Chrome-format trace of the Vulkan adapter's work,
|
||||
including shader and pipeline creation, readable in `ui.perfetto.dev`.
|
||||
[BENCHMARKING.md](BENCHMARKING.md) fixes the experiences to measure and
|
||||
`scripts/summarize_profile_trace.py` builds the before and after table.
|
||||
including shader and pipeline creation, readable in `ui.perfetto.dev`.
|
||||
[BENCHMARKING.md](BENCHMARKING.md) fixes the experiences to measure and
|
||||
`scripts/summarize_profile_trace.py` builds the before and after table.
|
||||
- Texture uploads no longer stall the frame they land on: ETC2 decode and
|
||||
resampling run on a persistent worker pool.
|
||||
resampling run on a persistent worker pool.
|
||||
- Less stutter while joining an experience and while textures load in. See
|
||||
the [changelog](../CHANGELOG.md) for the numbers.
|
||||
- The host main thread rests between engine polls instead of spinning, and
|
||||
GameMode's core pinning is released, so Roblox's workers spread across
|
||||
every core. See [PERFORMANCE.md](PERFORMANCE.md).
|
||||
GameMode's core pinning is released, so Roblox's workers spread across
|
||||
every core. See [PERFORMANCE.md](PERFORMANCE.md).
|
||||
- Own app ID `io.github.CoderDayton.nightcap`, so Nightcap installs next to
|
||||
upstream.
|
||||
upstream.
|
||||
- AppImage and signed Flatpak releases on every `v*` tag, with the Flatpak
|
||||
repo on GitHub Pages.
|
||||
repo on GitHub Pages.
|
||||
|
||||
## Not planned
|
||||
|
||||
- Replacing the `mocktail` binary and config names. Keeping them makes
|
||||
upstream merges clean.
|
||||
- DEB, RPM, and AUR packages. Upstream ships those for unmodified Mocktail.
|
||||
upstream merges clean.
|
||||
|
||||
@@ -49,6 +49,17 @@
|
||||
gdb
|
||||
];
|
||||
|
||||
desktopItems = [
|
||||
(pkgs.makeDesktopItem {
|
||||
name = "Mocktail";
|
||||
exec = "mocktail";
|
||||
icon = "mocktail";
|
||||
desktopName = "Mocktail";
|
||||
comment = "Experimental Roblox compatibility runtime for Linux and FreeBSD";
|
||||
categories = [ "Game" ];
|
||||
})
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath package.buildInputs}"
|
||||
|
||||
|
||||
@@ -33,6 +33,23 @@ void SetLegacyBionicDiagnosticsEnabled(bool enabled);
|
||||
// guest layout explicit instead of exposing the incompatible host libc type.
|
||||
using MocktailBionicMutexAttr = int64_t;
|
||||
|
||||
// Bionic LP64 pthread_attr_t: 56 bytes with explicit field offsets. The host
|
||||
// glibc layout is opaque and wider on aarch64, so guest buffers must be read
|
||||
// and written through this struct only.
|
||||
struct MocktailBionicPthreadAttr {
|
||||
std::uint32_t flags;
|
||||
void* stack_base;
|
||||
std::size_t stack_size;
|
||||
std::size_t guard_size;
|
||||
std::int32_t sched_policy;
|
||||
std::int32_t sched_priority;
|
||||
char reserved[16];
|
||||
};
|
||||
static_assert(sizeof(MocktailBionicPthreadAttr) == 56);
|
||||
|
||||
inline constexpr std::uint32_t kMocktailBionicAttrFlagDetached = 0x1;
|
||||
inline constexpr std::uint32_t kMocktailBionicAttrFlagUserStack = 0x2;
|
||||
|
||||
extern "C" {
|
||||
|
||||
void mocktail_set_current_jni_env(void* env);
|
||||
@@ -84,6 +101,19 @@ int mocktail_pthread_barrier_init(pthread_barrier_t* barrier,
|
||||
int mocktail_pthread_barrier_destroy(pthread_barrier_t* barrier);
|
||||
int mocktail_pthread_barrier_wait(pthread_barrier_t* barrier);
|
||||
|
||||
int mocktail_pthread_attr_init(MocktailBionicPthreadAttr* attr);
|
||||
int mocktail_pthread_attr_destroy(MocktailBionicPthreadAttr* attr);
|
||||
int mocktail_pthread_attr_setstacksize(MocktailBionicPthreadAttr* attr,
|
||||
size_t stack_size);
|
||||
int mocktail_pthread_attr_setdetachstate(MocktailBionicPthreadAttr* attr,
|
||||
int detach_state);
|
||||
int mocktail_pthread_attr_setschedparam(MocktailBionicPthreadAttr* attr,
|
||||
const struct sched_param* parameters);
|
||||
int mocktail_pthread_getattr_np(pthread_t thread,
|
||||
MocktailBionicPthreadAttr* attr);
|
||||
int mocktail_pthread_attr_getstack(const MocktailBionicPthreadAttr* attr,
|
||||
void** stack_base, size_t* stack_size);
|
||||
|
||||
extern void* mocktail_gameactivity_on_start_native;
|
||||
extern void* mocktail_gameactivity_on_resume_native;
|
||||
extern void* mocktail_gameactivity_on_surface_created_native;
|
||||
|
||||
@@ -11,19 +11,27 @@
|
||||
|
||||
namespace mocktail::compat {
|
||||
|
||||
// glibc's atoi is (int)strtol(), exactly like Bionic's, so the host symbol is
|
||||
// used as-is there. Other libcs (musl) differ on overflow and need the shim.
|
||||
#ifdef __GLIBC__
|
||||
inline constexpr bool kHostAtoiMatchesBionic = true;
|
||||
#else
|
||||
inline constexpr bool kHostAtoiMatchesBionic = false;
|
||||
#endif
|
||||
|
||||
// Android uses size_t fields here; glibc uses int and musl has no equivalent.
|
||||
// An all-zero fallback means unknown, not zero usage.
|
||||
struct BionicMallinfoSnapshot {
|
||||
size_t arena = 0;
|
||||
size_t ordblks = 0;
|
||||
size_t smblks = 0;
|
||||
size_t hblks = 0;
|
||||
size_t hblkhd = 0;
|
||||
size_t usmblks = 0;
|
||||
size_t fsmblks = 0;
|
||||
size_t uordblks = 0;
|
||||
size_t fordblks = 0;
|
||||
size_t keepcost = 0;
|
||||
size_t arena;
|
||||
size_t ordblks;
|
||||
size_t smblks;
|
||||
size_t hblks;
|
||||
size_t hblkhd;
|
||||
size_t usmblks;
|
||||
size_t fsmblks;
|
||||
size_t uordblks;
|
||||
size_t fordblks;
|
||||
size_t keepcost;
|
||||
};
|
||||
|
||||
struct BionicLocaleState;
|
||||
@@ -90,6 +98,7 @@ int mocktail_bionic_cxa_thread_atexit_impl(
|
||||
mocktail::compat::BionicThreadDestructor destructor, void* argument,
|
||||
void* dso_handle);
|
||||
void mocktail_bionic_arc4random_buf(void* buffer, size_t size);
|
||||
int mocktail_bionic_atoi(const char* text);
|
||||
mocktail::compat::BionicMallinfoSnapshot mocktail_bionic_mallinfo();
|
||||
int mocktail_bionic_sysinfo(struct sysinfo* info);
|
||||
int mocktail_bionic_uname(struct utsname* name);
|
||||
|
||||
@@ -25,11 +25,12 @@ void ConfigureBionicPthreadThreadInitializer(
|
||||
|
||||
} // namespace mocktail::compat
|
||||
|
||||
struct MocktailBionicPthreadAttr;
|
||||
|
||||
// Rebuilds attributes instead of passing Android pthread_attr_t to glibc.
|
||||
extern "C" int mocktail_bionic_pthread_create(pthread_t* thread,
|
||||
const pthread_attr_t* attr,
|
||||
void* (*start_routine)(void*),
|
||||
void* argument);
|
||||
extern "C" int mocktail_bionic_pthread_create(
|
||||
pthread_t* thread, const MocktailBionicPthreadAttr* attr,
|
||||
void* (*start_routine)(void*), void* argument);
|
||||
|
||||
// Guest real-time scheduling is denied to avoid the host RLIMIT_RTTIME watchdog.
|
||||
extern "C" int mocktail_bionic_pthread_setschedparam(
|
||||
|
||||
@@ -36,6 +36,11 @@ struct FmodOutputDeviceBridgeProfile {
|
||||
? std::array<std::size_t, 4>{9, 10, 12, 18}
|
||||
: std::array<std::size_t, 4>{8, 9, 10, 16};
|
||||
}
|
||||
std::array<std::size_t, 6> capture_vtable_indexes() const {
|
||||
return vtable_layout_version == 2
|
||||
? std::array<std::size_t, 6>{4, 13, 14, 15, 16, 17}
|
||||
: std::array<std::size_t, 6>{4, 11, 12, 13, 14, 15};
|
||||
}
|
||||
|
||||
bool valid_vtable_layout() const {
|
||||
return vtable_layout_version == 1 || vtable_layout_version == 2;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef MOCKTAIL_COMPAT_GUEST_ABI_H_
|
||||
#define MOCKTAIL_COMPAT_GUEST_ABI_H_
|
||||
|
||||
#include <elf.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace mocktail::compat {
|
||||
|
||||
#if defined(__aarch64__)
|
||||
// Android ABI name as it appears in APK lib/ directories and build metadata.
|
||||
inline constexpr std::string_view kGuestAbi = "arm64-v8a";
|
||||
// APK split-config name carrying the guest native libraries.
|
||||
inline constexpr std::string_view kGuestApkSplitName = "config.arm64_v8a";
|
||||
// File name the payload store uses for the split APK.
|
||||
inline constexpr std::string_view kGuestSplitApkFile =
|
||||
"split_config.arm64_v8a.apk";
|
||||
// sha256 map key holding the split APK digest in payload metadata.
|
||||
inline constexpr std::string_view kGuestSplitApkHashKey = "arm64_v8a_split_apk";
|
||||
// Short CPU label for device metadata and user-facing strings.
|
||||
inline constexpr std::string_view kGuestCpuName = "aarch64";
|
||||
inline constexpr int kGuestElfMachine = EM_AARCH64;
|
||||
#elif defined(__x86_64__)
|
||||
inline constexpr std::string_view kGuestAbi = "x86_64";
|
||||
inline constexpr std::string_view kGuestApkSplitName = "config.x86_64";
|
||||
inline constexpr std::string_view kGuestSplitApkFile = "split_config.x86_64.apk";
|
||||
inline constexpr std::string_view kGuestSplitApkHashKey = "x86_64_split_apk";
|
||||
inline constexpr std::string_view kGuestCpuName = "x86_64";
|
||||
inline constexpr int kGuestElfMachine = EM_X86_64;
|
||||
#else
|
||||
#error "mocktail only supports aarch64 and x86_64 hosts"
|
||||
#endif
|
||||
|
||||
// APK zip entry holding the guest libroblox.so.
|
||||
inline constexpr std::string_view kGuestLibApkEntryPrefix = "lib/";
|
||||
|
||||
} // namespace mocktail::compat
|
||||
|
||||
#endif // MOCKTAIL_COMPAT_GUEST_ABI_H_
|
||||
@@ -109,6 +109,15 @@ struct HostAbiProfile {
|
||||
size_t NativeMimallocConstructorRangeEndExclusive() const noexcept;
|
||||
bool ShouldInitializeNativeMimallocThreadAfterConstructor(
|
||||
size_t index) const noexcept;
|
||||
// True when both replays have the one verified shape. The native replay is
|
||||
// one range that runs to the end of .init_array. Its first four
|
||||
// constructors are the process-load constructor at the thread-initializer
|
||||
// checkpoint, the JNI singleton initializer, and two wiring entries. The
|
||||
// host-bridge replay runs the same constructors without the two wiring
|
||||
// entries. `jni_singleton_constructor` is the .init_array index of the JNI
|
||||
// singleton initializer.
|
||||
bool HasVerifiedConstructorPolicy(
|
||||
size_t jni_singleton_constructor) const noexcept;
|
||||
bool HasValidNativePreJniBootstrap() const noexcept;
|
||||
HostAllocatorStrategy ResolveAllocatorStrategy(
|
||||
bool host_bridges_override_present,
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
#ifndef MOCKTAIL_COMPAT_WEB_VIEW_PROTOCOL_CONTRACT_H_
|
||||
#define MOCKTAIL_COMPAT_WEB_VIEW_PROTOCOL_CONTRACT_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
// Roblox's Subsystem<IWebViewProtocol> getter is not exported. The exported
|
||||
// WebViewProtocol.initializeAndroidWebViewProtocol calls it first, into a
|
||||
// stack slot, then reads the protocol from the returned holder:
|
||||
//
|
||||
// x86-64: lea slot(%rbp),%rbx; mov %rbx,%rdi; call getter;
|
||||
// mov (%rbx),%rbx; mov 0x18(%rbx),%rax
|
||||
// AArch64: add x8, sp, #slot; bl getter; ldr xN, [sp, #slot];
|
||||
// ldr x8, [xN, #0x18]
|
||||
//
|
||||
// These functions find that call site in the initializer's first bytes and
|
||||
// check the getter's own code. Only relocated or build-varying fields (stack
|
||||
// slots, frame sizes, PC-relative offsets, the call target) are masked.
|
||||
// Verified on x86_64 2.734.917, 2.736.1408 and 2.738.1397, and on arm64-v8a
|
||||
// 2.738.1397 and 2.740.931.
|
||||
|
||||
namespace mocktail::compat {
|
||||
|
||||
// Covers the call site in every verified build (x86-64 +0x27, AArch64 +0x34).
|
||||
inline constexpr std::size_t kWebViewProtocolInitializerScanBytes = 128;
|
||||
inline constexpr std::size_t kWebViewProtocolGetterBytesX86_64 = 44;
|
||||
inline constexpr std::size_t kWebViewProtocolGetterBytesArm64 = 60;
|
||||
|
||||
namespace web_view_protocol_contract_detail {
|
||||
|
||||
inline bool MatchesMasked(std::string_view code, std::size_t offset,
|
||||
std::string_view pattern,
|
||||
std::string_view wildcard) {
|
||||
if (offset > code.size() || code.size() - offset < pattern.size()) {
|
||||
return false;
|
||||
}
|
||||
for (std::size_t index = 0; index < pattern.size(); ++index) {
|
||||
if (wildcard[index] == 'x') continue;
|
||||
if (code[offset + index] != pattern[index]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// AArch64 instructions are little-endian words.
|
||||
inline std::uint32_t Word(std::string_view code, std::size_t index) {
|
||||
std::uint32_t word = 0;
|
||||
for (std::size_t byte = 0; byte < 4; ++byte) {
|
||||
word |= static_cast<std::uint32_t>(
|
||||
static_cast<unsigned char>(code[index * 4 + byte]))
|
||||
<< (8 * byte);
|
||||
}
|
||||
return word;
|
||||
}
|
||||
|
||||
// One AArch64 instruction word: bits outside `mask` may vary.
|
||||
struct MaskedWord {
|
||||
std::uint32_t mask;
|
||||
std::uint32_t value;
|
||||
};
|
||||
|
||||
inline constexpr std::uint32_t kExact = 0xffffffffU;
|
||||
// adrp Xd, page: immlo and immhi vary.
|
||||
inline constexpr std::uint32_t kAdrpMask = 0x9f00001fU;
|
||||
// add Xd, Xn, #imm12: imm12 varies.
|
||||
inline constexpr std::uint32_t kAddImmediateMask = 0xffc003ffU;
|
||||
|
||||
} // namespace web_view_protocol_contract_detail
|
||||
|
||||
// Returns the getter address called from the x86-64 initializer at
|
||||
// `address`, or nullopt unless the frame setup and exactly one call site
|
||||
// match.
|
||||
inline std::optional<std::uintptr_t> FindWebViewProtocolGetterCallX86_64(
|
||||
std::string_view code, std::uintptr_t address) {
|
||||
using web_view_protocol_contract_detail::MatchesMasked;
|
||||
// push %rbp; mov %rsp,%rbp
|
||||
if (!MatchesMasked(code, 0, "\x55\x48\x89\xe5", "....")) {
|
||||
return std::nullopt;
|
||||
}
|
||||
static constexpr std::string_view kCallSite(
|
||||
"\x48\x8d\x5d\x00\x48\x89\xdf\xe8\x00\x00\x00\x00\x48\x8b\x1b\x48\x8b\x43"
|
||||
"\x18",
|
||||
19);
|
||||
static constexpr std::string_view kCallSiteWildcard("...x....xxxx.......");
|
||||
static constexpr std::size_t kCallDisplacement = 8;
|
||||
const std::string_view window =
|
||||
code.substr(0, kWebViewProtocolInitializerScanBytes);
|
||||
std::optional<std::size_t> call_site;
|
||||
for (std::size_t offset = 0; offset < window.size(); ++offset) {
|
||||
if (MatchesMasked(window, offset, kCallSite, kCallSiteWildcard)) {
|
||||
if (call_site.has_value()) return std::nullopt;
|
||||
call_site = offset;
|
||||
}
|
||||
}
|
||||
if (!call_site.has_value()) return std::nullopt;
|
||||
std::int32_t displacement = 0;
|
||||
std::memcpy(&displacement, window.data() + *call_site + kCallDisplacement,
|
||||
sizeof(displacement));
|
||||
const std::uintptr_t next_instruction =
|
||||
address + *call_site + kCallDisplacement + sizeof(displacement);
|
||||
return next_instruction +
|
||||
static_cast<std::uintptr_t>(static_cast<std::intptr_t>(displacement));
|
||||
}
|
||||
|
||||
// The x86-64 getter stores the holder returned by the subsystem's acquire
|
||||
// into its result slot (%rdi) and returns that slot.
|
||||
inline bool HasWebViewProtocolGetterContractX86_64(std::string_view code) {
|
||||
return web_view_protocol_contract_detail::MatchesMasked(
|
||||
code, 0,
|
||||
std::string_view(
|
||||
"\x55\x48\x89\xe5\x53\x50\x48\x89\xfb\x8a\x05\x00\x00\x00\x00\x84\xc0"
|
||||
"\x74\x19\x48\x8d\x3d\x00\x00\x00\x00\xe8\x59\x00\x00\x00\x48\x89\x03"
|
||||
"\x48\x89\xd8\x48\x83\xc4\x08\x5b\x5d\xc3",
|
||||
kWebViewProtocolGetterBytesX86_64),
|
||||
"...........xxxx.......xxxx..................");
|
||||
}
|
||||
|
||||
// Returns the getter address called from the AArch64 initializer at
|
||||
// `address`, or nullopt unless exactly one call site matches.
|
||||
inline std::optional<std::uintptr_t> FindWebViewProtocolGetterCallArm64(
|
||||
std::string_view code, std::uintptr_t address) {
|
||||
using web_view_protocol_contract_detail::Word;
|
||||
const std::size_t words =
|
||||
code.substr(0, kWebViewProtocolInitializerScanBytes).size() / 4;
|
||||
std::optional<std::uintptr_t> getter;
|
||||
for (std::size_t index = 0; index + 4 <= words; ++index) {
|
||||
const std::uint32_t slot_address = Word(code, index);
|
||||
const std::uint32_t call = Word(code, index + 1);
|
||||
const std::uint32_t handle_load = Word(code, index + 2);
|
||||
const std::uint32_t protocol_load = Word(code, index + 3);
|
||||
// add x8, sp, #slot
|
||||
if ((slot_address & 0xffc003ffU) != 0x910003e8U) continue;
|
||||
// bl getter
|
||||
if ((call & 0xfc000000U) != 0x94000000U) continue;
|
||||
// ldr xN, [sp, #slot]
|
||||
if ((handle_load & 0xffc003e0U) != 0xf94003e0U) continue;
|
||||
const std::uint32_t slot = (slot_address >> 10) & 0xfffU;
|
||||
if (((handle_load >> 10) & 0xfffU) * 8 != slot) continue;
|
||||
// ldr x8, [xN, #0x18]
|
||||
const std::uint32_t handle_register = handle_load & 0x1fU;
|
||||
if (protocol_load != (0xf9400c08U | (handle_register << 5))) continue;
|
||||
if (getter.has_value()) return std::nullopt;
|
||||
// imm26 is a signed word offset from the bl instruction.
|
||||
const std::int64_t imm26 = call & 0x03ffffffU;
|
||||
const std::int64_t words_from_call =
|
||||
(imm26 & 0x02000000) != 0 ? imm26 - 0x04000000 : imm26;
|
||||
getter = address + (index + 1) * 4 +
|
||||
static_cast<std::uintptr_t>(words_from_call * 4);
|
||||
}
|
||||
return getter;
|
||||
}
|
||||
|
||||
// The AArch64 getter saves its result slot (x8) and stores the holder
|
||||
// returned by the subsystem's acquire there.
|
||||
inline bool HasWebViewProtocolGetterContractArm64(std::string_view code) {
|
||||
using namespace web_view_protocol_contract_detail;
|
||||
static constexpr MaskedWord kGetter[] = {
|
||||
{kExact, 0xa9be7bfdU}, // stp x29, x30, [sp, #-0x20]!
|
||||
{kExact, 0xf9000bf3U}, // str x19, [sp, #0x10]
|
||||
{kExact, 0x910003fdU}, // mov x29, sp
|
||||
{kAdrpMask, 0x90000009U}, // adrp x9, guard
|
||||
{kAddImmediateMask, 0x91000129U}, // add x9, x9, :lo12:guard
|
||||
{kExact, 0xaa0803f3U}, // mov x19, x8
|
||||
{kExact, 0x08dffd29U}, // ldarb w9, [x9]
|
||||
{kExact, 0x36000109U}, // tbz w9, #0, initialize
|
||||
{kAdrpMask, 0x90000000U}, // adrp x0, holder
|
||||
{kAddImmediateMask, 0x91000000U}, // add x0, x0, :lo12:holder
|
||||
{kExact, 0x94000017U}, // bl acquire
|
||||
{kExact, 0xf9000260U}, // str x0, [x19]
|
||||
{kExact, 0xf9400bf3U}, // ldr x19, [sp, #0x10]
|
||||
{kExact, 0xa8c27bfdU}, // ldp x29, x30, [sp], #0x20
|
||||
{kExact, 0xd65f03c0U}, // ret
|
||||
};
|
||||
static_assert(sizeof(kGetter) / sizeof(kGetter[0]) * 4 ==
|
||||
kWebViewProtocolGetterBytesArm64);
|
||||
if (code.size() < kWebViewProtocolGetterBytesArm64) return false;
|
||||
for (std::size_t index = 0; index < sizeof(kGetter) / sizeof(kGetter[0]);
|
||||
++index) {
|
||||
if ((Word(code, index) & kGetter[index].mask) != kGetter[index].value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mocktail::compat
|
||||
|
||||
#endif // MOCKTAIL_COMPAT_WEB_VIEW_PROTOCOL_CONTRACT_H_
|
||||
@@ -48,9 +48,15 @@ struct PlatformIdentity {
|
||||
std::string manufacturer = "Mocktail";
|
||||
std::string model = "Mocktail Headless";
|
||||
std::string brand = "Mocktail";
|
||||
#if defined(__aarch64__)
|
||||
std::string device_code = "linux-arm64";
|
||||
std::string device_sku = "mocktail-arm64";
|
||||
std::string soc_model = "aarch64";
|
||||
#else
|
||||
std::string device_code = "linux-x86_64";
|
||||
std::string device_sku = "mocktail-x86_64";
|
||||
std::string soc_model = "x86_64";
|
||||
#endif
|
||||
};
|
||||
|
||||
struct RobloxCredentialView {
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#if defined(__x86_64__)
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
#if defined(__aarch64__)
|
||||
#include <cstdint>
|
||||
#endif
|
||||
|
||||
namespace mocktail::audio {
|
||||
|
||||
@@ -22,16 +25,23 @@ class FmodThreadFloatingPointMode final {
|
||||
delete;
|
||||
|
||||
bool Enable(const char* thread_name) noexcept {
|
||||
#if defined(__x86_64__)
|
||||
#if defined(__x86_64__) || defined(__aarch64__)
|
||||
if (active_ || thread_name == nullptr) return false;
|
||||
const std::string_view name(thread_name);
|
||||
if (name != "FMOD mixer thread" && name != "FMOD feeder thread" &&
|
||||
name != "FMOD Convolution thread" && name != "FMOD Worker Thread") {
|
||||
return false;
|
||||
}
|
||||
#if defined(__x86_64__)
|
||||
const unsigned int control = _mm_getcsr();
|
||||
original_mode_ = control & kModeMask;
|
||||
_mm_setcsr(control | kModeMask);
|
||||
#else
|
||||
std::uint64_t control;
|
||||
__asm__ volatile("mrs %0, fpcr" : "=r"(control));
|
||||
original_mode_ = control & kModeMask;
|
||||
__asm__ volatile("msr fpcr, %0" ::"r"(control | kModeMask));
|
||||
#endif
|
||||
active_ = true;
|
||||
return true;
|
||||
#else
|
||||
@@ -41,11 +51,18 @@ class FmodThreadFloatingPointMode final {
|
||||
}
|
||||
|
||||
void Restore() noexcept {
|
||||
#if defined(__x86_64__)
|
||||
#if defined(__x86_64__) || defined(__aarch64__)
|
||||
if (active_) {
|
||||
// Restore only our two bits, preserving rounding, exception masks and
|
||||
// status flags set by the guest while the thread was attached.
|
||||
#if defined(__x86_64__)
|
||||
_mm_setcsr((_mm_getcsr() & ~kModeMask) | original_mode_);
|
||||
#else
|
||||
std::uint64_t control;
|
||||
__asm__ volatile("mrs %0, fpcr" : "=r"(control));
|
||||
__asm__ volatile("msr fpcr, %0" ::"r"((control & ~kModeMask) |
|
||||
original_mode_));
|
||||
#endif
|
||||
active_ = false;
|
||||
}
|
||||
#endif
|
||||
@@ -56,6 +73,13 @@ class FmodThreadFloatingPointMode final {
|
||||
static constexpr unsigned int kModeMask = (1U << 15) | (1U << 6);
|
||||
unsigned int original_mode_ = 0;
|
||||
bool active_ = false;
|
||||
#elif defined(__aarch64__)
|
||||
// FPCR FZ flushes single/double subnormals; FZ16 covers the half-precision
|
||||
// path used by some voice DSP filters.
|
||||
static constexpr std::uint64_t kModeMask =
|
||||
(std::uint64_t{1} << 24) | (std::uint64_t{1} << 19);
|
||||
std::uint64_t original_mode_ = 0;
|
||||
bool active_ = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ class RobloxOutputDeviceBridge final {
|
||||
void SelectDevice(int index, bool input = false);
|
||||
void ConstructGuestString(void* destination, std::string_view value) const;
|
||||
|
||||
std::unique_ptr<NativeInputCapture> capture_;
|
||||
bool capture_profile_supported_ = false;
|
||||
std::shared_ptr<NativeInputCapture> capture_;
|
||||
std::array<std::uintptr_t, 6> original_capture_methods_{};
|
||||
mutable std::mutex mutex_;
|
||||
compat::FmodOutputDeviceBridgeProfile profile_;
|
||||
|
||||
@@ -16,6 +16,9 @@ struct AngleProbeOptions {
|
||||
bool allow_software_device = false;
|
||||
};
|
||||
|
||||
// Checks ANGLE entry points and client extensions without initializing a display.
|
||||
BackendCapability InspectAngleLibraries(const AngleProbeOptions& options);
|
||||
|
||||
// Loads a pinned ANGLE pair, verifies the required EGL/GLES symbols, and
|
||||
// initializes an EGL_PLATFORM_ANGLE Vulkan display. No context is fabricated.
|
||||
BackendCapability ProbeAngleVulkan(const AngleProbeOptions& options);
|
||||
|
||||
@@ -24,6 +24,35 @@ struct TraceArg {
|
||||
|
||||
// CLOCK_MONOTONIC in nanoseconds.
|
||||
std::uint64_t TraceClockNanos();
|
||||
// CPU time used so far by the calling thread, in nanoseconds.
|
||||
std::uint64_t TraceThreadCpuNanos();
|
||||
// CPU time used so far by every thread of the process, in nanoseconds.
|
||||
std::uint64_t TraceProcessCpuNanos();
|
||||
|
||||
// CPU time spent between two successive presents.
|
||||
struct FrameCpuSample {
|
||||
double process_ms = 0;
|
||||
// Set only when the previous present came from the same thread; thread CPU
|
||||
// clocks of different threads cannot be subtracted.
|
||||
bool has_thread = false;
|
||||
double thread_ms = 0;
|
||||
};
|
||||
|
||||
// Turns CPU clocks read at each present into per-frame CPU time.
|
||||
// Thread-safe.
|
||||
class FrameCpuSampler final {
|
||||
public:
|
||||
// Returns false for the first present, which ends no frame.
|
||||
bool Sample(std::uint64_t thread_id, std::uint64_t thread_cpu_ns,
|
||||
std::uint64_t process_cpu_ns, FrameCpuSample* sample);
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
bool has_previous_ = false;
|
||||
std::uint64_t previous_thread_id_ = 0;
|
||||
std::uint64_t previous_thread_cpu_ns_ = 0;
|
||||
std::uint64_t previous_process_cpu_ns_ = 0;
|
||||
};
|
||||
|
||||
// Writes the Trace Event Format JSON array read by chrome://tracing and
|
||||
// ui.perfetto.dev. Recording threads only format into a shared buffer; a
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define MOCKTAIL_GRAPHICS_PRESENT_MODE_POLICY_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
@@ -29,6 +30,36 @@ FilterPresentModes(PresentModePolicy policy,
|
||||
const char *PresentModePolicyName(PresentModePolicy policy);
|
||||
const char *PresentModeKhrName(VkPresentModeKHR mode);
|
||||
|
||||
// Creates the swapchain with the mode in `info`. A driver can reject a mode
|
||||
// that the device did not enable, so a failed create is retried once with the
|
||||
// mode the game asked for. `create` takes the info and returns a VkResult.
|
||||
template <typename Create>
|
||||
VkResult CreateSwapchainWithPresentModeFallback(VkSwapchainCreateInfoKHR &info,
|
||||
VkPresentModeKHR requested,
|
||||
Create create) {
|
||||
const VkResult result = create(info);
|
||||
if (result == VK_SUCCESS || info.presentMode == requested) {
|
||||
return result;
|
||||
}
|
||||
switch (result) {
|
||||
case VK_ERROR_OUT_OF_HOST_MEMORY:
|
||||
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
|
||||
case VK_ERROR_DEVICE_LOST:
|
||||
case VK_ERROR_SURFACE_LOST_KHR:
|
||||
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
|
||||
return result; // Another present mode cannot fix these.
|
||||
default:
|
||||
break;
|
||||
}
|
||||
std::fprintf(stderr,
|
||||
" [vulkan] swapchain presentMode %s failed (%d); retrying "
|
||||
"with %s\n",
|
||||
PresentModeKhrName(info.presentMode), static_cast<int>(result),
|
||||
PresentModeKhrName(requested));
|
||||
info.presentMode = requested;
|
||||
return create(info);
|
||||
}
|
||||
|
||||
// Extra images so acquire does not wait on the compositor-held buffer.
|
||||
std::uint32_t PreferSwapchainMinImageCount(PresentModePolicy policy,
|
||||
std::uint32_t requested,
|
||||
|
||||
@@ -35,6 +35,10 @@ void ResampleRgba(const RgbaImage& source, std::uint32_t width,
|
||||
void ResampleRgba(const std::uint8_t* source, std::uint32_t source_width,
|
||||
std::uint32_t source_height, std::uint32_t width,
|
||||
std::uint32_t height, std::uint8_t* destination);
|
||||
void ResampleRgba(const std::uint8_t* source, std::uint32_t source_width,
|
||||
std::uint32_t source_height, std::size_t source_stride_bytes,
|
||||
std::uint32_t width, std::uint32_t height,
|
||||
std::uint8_t* destination);
|
||||
|
||||
// Replacement textures keyed by the hash of a texture's level-0 compressed
|
||||
// bytes. An override lives at <override_dir>/<hash>.png. With a dump
|
||||
|
||||
@@ -30,6 +30,18 @@ bool Etc2UploadByteCounts(EtcFormat format, const VkExtent3D& extent,
|
||||
std::uint32_t layer_count, VkDeviceSize* compressed,
|
||||
VkDeviceSize* decoded);
|
||||
|
||||
// Sums every mip level and layer; `scale` multiplies the host image's
|
||||
// level-0 width and height only.
|
||||
bool Etc2ImageByteCounts(EtcFormat format, const VkExtent3D& extent,
|
||||
std::uint32_t mip_levels, std::uint32_t layers,
|
||||
std::uint32_t scale, VkDeviceSize* compressed,
|
||||
VkDeviceSize* decoded);
|
||||
|
||||
struct EmulatedTextureBytes {
|
||||
VkDeviceSize compressed = 0;
|
||||
VkDeviceSize decoded = 0;
|
||||
};
|
||||
|
||||
// Whether emulated ETC2 is reported to the application as a supported
|
||||
// feature, from the MOCKTAIL_ADVERTISE_ETC2 value: "0" hides it, anything
|
||||
// else (or unset) reports it. Hidden ETC2 still decodes ETC2 images the
|
||||
@@ -47,17 +59,30 @@ inline constexpr std::uint32_t kSmallTextureMaxExtent = 64;
|
||||
inline constexpr std::uint32_t kDefaultSmallTextureUpscale = 4;
|
||||
std::uint32_t SmallTextureUpscale(const char* value);
|
||||
|
||||
// Staging for decoded uploads is carved out of host-visible blocks this
|
||||
// large; an upload that needs more gets a block of its own.
|
||||
inline constexpr VkDeviceSize kEtc2StagingBlockBytes = 16 * 1024 * 1024;
|
||||
|
||||
// A timeline semaphore and the value an asynchronous decode will signal.
|
||||
// `semaphore` is VK_NULL_HANDLE when the decode already finished on the
|
||||
// calling thread and the submit needs no extra wait.
|
||||
struct Etc2SubmitWait {
|
||||
VkSemaphore semaphore = VK_NULL_HANDLE;
|
||||
std::uint64_t value = 0;
|
||||
};
|
||||
|
||||
// Reports ETC2/EAC support on hosts without native ETC2 (desktop GPUs) and
|
||||
// stores those textures decoded. Images are created with the host format;
|
||||
// each staged upload into one is redirected to a host-visible staging buffer
|
||||
// that is filled by decoding the application's staging bytes when the
|
||||
// command buffer is submitted. Every submit decodes again, as a native copy
|
||||
// re-reads its source on each execution.
|
||||
// Staging buffers live until their command buffer is begun, reset or freed.
|
||||
// Staging ranges live until their command buffer is begun, reset or freed.
|
||||
// MOCKTAIL_DISABLE_ETC2_EMULATION=1 turns the emulation off.
|
||||
class VulkanEtc2Emulation final {
|
||||
public:
|
||||
VulkanEtc2Emulation();
|
||||
explicit VulkanEtc2Emulation(
|
||||
VkDeviceSize staging_block_bytes = kEtc2StagingBlockBytes);
|
||||
~VulkanEtc2Emulation();
|
||||
VulkanEtc2Emulation(const VulkanEtc2Emulation&) = delete;
|
||||
VulkanEtc2Emulation& operator=(const VulkanEtc2Emulation&) = delete;
|
||||
@@ -66,10 +91,14 @@ class VulkanEtc2Emulation final {
|
||||
bool PhysicalDeviceNeedsEmulation(VkPhysicalDevice physical_device,
|
||||
PFN_vkGetPhysicalDeviceFeatures host);
|
||||
|
||||
// `timeline_semaphore` states whether the device was created with the
|
||||
// timelineSemaphore feature enabled. Without it every decode runs on the
|
||||
// calling thread.
|
||||
void RegisterDevice(VkDevice device, VkPhysicalDevice physical_device,
|
||||
bool emulated,
|
||||
const VkPhysicalDeviceMemoryProperties& memory,
|
||||
PFN_vkGetDeviceProcAddr get_device_proc_addr);
|
||||
PFN_vkGetDeviceProcAddr get_device_proc_addr,
|
||||
bool timeline_semaphore = false);
|
||||
void DestroyDevice(VkDevice device);
|
||||
|
||||
VkResult CreateImage(VkDevice device, const VkImageCreateInfo* create_info,
|
||||
@@ -112,14 +141,33 @@ class VulkanEtc2Emulation final {
|
||||
const VkCommandBuffer* secondaries);
|
||||
|
||||
// Decodes every upload recorded into these command buffers and the
|
||||
// secondary command buffers they execute. Large batches decode on worker
|
||||
// threads; this returns once every upload is decoded.
|
||||
void PrepareSubmit(const VkCommandBuffer* command_buffers,
|
||||
std::uint32_t count);
|
||||
// secondary command buffers they execute.
|
||||
//
|
||||
// With `allow_async` on a device that has a timeline semaphore, the decode
|
||||
// runs on worker threads, and so does the gather of the compressed bytes
|
||||
// whenever the application already has them mapped. The returned semaphore
|
||||
// and value must then be added to the submit's waits, so the GPU copy
|
||||
// cannot execute before the decode finishes. Values are signalled in the
|
||||
// order they are handed out.
|
||||
//
|
||||
// Those threads read the application's source bytes after this returns,
|
||||
// which Vulkan allows: the application may not write them between the
|
||||
// submit and the copy's completion. Unmapping or freeing that memory waits
|
||||
// for the decodes still reading it.
|
||||
//
|
||||
// Returns `{VK_NULL_HANDLE, 0}` when there was nothing to decode, when
|
||||
// `allow_async` is false, or when the device has no timeline semaphore. In
|
||||
// those cases every upload is already decoded when this returns.
|
||||
Etc2SubmitWait PrepareSubmit(const VkCommandBuffer* command_buffers,
|
||||
std::uint32_t count, bool allow_async = false);
|
||||
// Destroys the staging buffers owned by a command buffer that is no longer
|
||||
// pending.
|
||||
// pending, after waiting for any decode still writing into them.
|
||||
void ReleaseCommandBuffer(VkCommandBuffer command_buffer);
|
||||
|
||||
// Traced as the "emulated texture (MB)" and "compressed texture (MB)"
|
||||
// counters.
|
||||
EmulatedTextureBytes TextureBytes() const;
|
||||
|
||||
struct State;
|
||||
|
||||
private:
|
||||
|
||||
@@ -152,6 +152,10 @@ struct MouseMotionEvent {
|
||||
float delta_x = 0.0f;
|
||||
float delta_y = 0.0f;
|
||||
std::uint32_t buttons = 0;
|
||||
// True while the window holds relative mouse mode. The absolute coordinates
|
||||
// are meaningless then: X11 reports zeroes, Wayland reports a position that
|
||||
// accumulates the deltas and can leave the window entirely.
|
||||
bool relative = false;
|
||||
};
|
||||
|
||||
struct MouseButtonEvent {
|
||||
@@ -160,6 +164,8 @@ struct MouseButtonEvent {
|
||||
std::uint8_t clicks = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
// See MouseMotionEvent::relative.
|
||||
bool relative = false;
|
||||
};
|
||||
|
||||
struct MouseWheelEvent {
|
||||
@@ -167,6 +173,8 @@ struct MouseWheelEvent {
|
||||
float delta_y = 0.0f;
|
||||
float mouse_x = 0.0f;
|
||||
float mouse_y = 0.0f;
|
||||
// See MouseMotionEvent::relative.
|
||||
bool relative = false;
|
||||
};
|
||||
|
||||
struct TouchEvent {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_ASSET_OVERLAY_NAMES_H_
|
||||
#define MOCKTAIL_RUNTIME_ASSET_OVERLAY_NAMES_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
|
||||
// The rbxasset:// name of every regular file under <overlay_dir>/content, such
|
||||
// as rbxasset://textures/MouseLockedCursor.png. Sorted.
|
||||
std::vector<std::string> OverlayRbxAssetNames(
|
||||
const std::filesystem::path& overlay_dir);
|
||||
|
||||
// Roblox opens no local file for an rbxasset:// name it maps to a download.
|
||||
// Writes '!' over the first byte of each whole NUL-terminated copy of a name
|
||||
// in `data`, which unmaps it. Returns the number of copies changed.
|
||||
std::size_t DisableAssetNameMappings(std::uint8_t* data, std::size_t size,
|
||||
const std::vector<std::string>& names);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,26 @@ std::string SelectVulkanIcdManifest(
|
||||
const std::vector<std::filesystem::path>& directories,
|
||||
std::string_view vendor);
|
||||
|
||||
// One GPU as the kernel reports it.
|
||||
struct HostGpu {
|
||||
unsigned int vendor = 0; // PCI vendor ID.
|
||||
std::string kernel_driver; // Bound kernel driver; empty when unknown.
|
||||
};
|
||||
|
||||
struct VulkanIcdSelection {
|
||||
std::string manifest; // Empty when no GPU has a usable driver.
|
||||
std::vector<std::string> skipped; // Why each passed-over GPU was skipped.
|
||||
};
|
||||
|
||||
// ICD manifest for the first GPU whose bound kernel driver has an installed
|
||||
// Vulkan driver. NVIDIA and AMD cards are tried before Intel when
|
||||
// `prefer_discrete` is set, and after it otherwise. A GPU with an unknown
|
||||
// kernel driver is matched by vendor alone.
|
||||
VulkanIcdSelection SelectHostVulkanIcd(
|
||||
const std::vector<HostGpu>& gpus,
|
||||
const std::vector<std::filesystem::path>& directories,
|
||||
bool prefer_discrete);
|
||||
|
||||
// Publishes the resolved graphics backend before the managed payload updater
|
||||
// starts. OpenGL is a strict system EGL/GLES path; it never silently retries
|
||||
// through ANGLE/Vulkan or accepts a window without a real graphics context.
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_LUAU_CODEGEN_SWITCH_H_
|
||||
#define MOCKTAIL_RUNTIME_LUAU_CODEGEN_SWITCH_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "runtime/roblox_experience_presence.h"
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
|
||||
// Nightcap defaults this on and keeps it on only outside games; a user value
|
||||
// set in fflags.json or the overrides environment disables the switching.
|
||||
inline constexpr std::string_view kLuauCodegenAllClientSetting =
|
||||
"FFlagDebugLuauCodegenAll";
|
||||
inline constexpr std::string_view kLuauCodegenAllFastFlagName =
|
||||
"DebugLuauCodegenAll";
|
||||
|
||||
struct LoadedImageSegment {
|
||||
std::uintptr_t address = 0;
|
||||
std::size_t size = 0;
|
||||
bool writable = false;
|
||||
};
|
||||
|
||||
std::vector<LoadedImageSegment> LoadedImageSegments(std::uintptr_t image_base);
|
||||
|
||||
// Record layout: {u8 value; pad; const char* name; size_t length}, in a
|
||||
// writable segment filled by libroblox's static constructors. Returns null
|
||||
// unless exactly one record names a NUL-terminated copy of `name`.
|
||||
std::uint8_t* FindFastFlagValue(
|
||||
const std::vector<LoadedImageSegment>& segments, std::string_view name);
|
||||
|
||||
bool ClientSettingsSetLuauCodegenAll(std::string_view overrides_json);
|
||||
|
||||
bool LuauCodegenAllForPhase(RobloxExperiencePresencePhase phase);
|
||||
|
||||
// Locates the flag on the first notification; a byte that is not 0 or 1 is
|
||||
// left alone.
|
||||
class LuauCodegenMenuSwitch {
|
||||
public:
|
||||
using LocateFlagFn = std::function<std::uint8_t*()>;
|
||||
|
||||
LuauCodegenMenuSwitch(LocateFlagFn locate_flag,
|
||||
RobloxExperiencePresenceObserver next);
|
||||
|
||||
RobloxExperiencePresenceObserver observer();
|
||||
void OnPhase(RobloxExperiencePresencePhase phase,
|
||||
const RobloxExperienceLaunchRequest* request);
|
||||
|
||||
private:
|
||||
static void Notify(void* context, RobloxExperiencePresencePhase phase,
|
||||
const RobloxExperienceLaunchRequest* request);
|
||||
|
||||
std::mutex mutex_;
|
||||
LocateFlagFn locate_flag_;
|
||||
bool located_ = false;
|
||||
std::uint8_t* flag_ = nullptr;
|
||||
const RobloxExperiencePresenceObserver next_;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace mocktail
|
||||
|
||||
#endif // MOCKTAIL_RUNTIME_LUAU_CODEGEN_SWITCH_H_
|
||||
@@ -47,8 +47,8 @@ struct RobloxThemeCacheResult {
|
||||
};
|
||||
|
||||
// Reads the current account's Roblox theme without changing appStorage. A
|
||||
// missing value leaves dark_theme empty so the caller can use Roblox's own
|
||||
// startup default.
|
||||
// missing or unrecognized value falls back to AuthenticatedTheme, then the
|
||||
// caller's startup default.
|
||||
RobloxThemeCacheResult ReadRobloxThemeCache(
|
||||
const std::filesystem::path& app_storage_file,
|
||||
std::int64_t authenticated_user_id);
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_ROBLOX_ACCOUNT_BRIDGE_H_
|
||||
#define MOCKTAIL_RUNTIME_ROBLOX_ACCOUNT_BRIDGE_H_
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "mocktail/status.h"
|
||||
#include "runtime/roblox_game_session_native_adapter.h"
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
|
||||
// Exact JNI entrypoints behind the APK AccountProtocol device-integrity
|
||||
// handlers: JNIAccountProtocol name getters and MessageBus raw handlers.
|
||||
struct RobloxAccountProtocolSymbols {
|
||||
using GetStringFn = jstring (*)(JNIEnv*, jclass);
|
||||
|
||||
GetStringFn get_protocol_name = nullptr;
|
||||
GetStringFn get_device_integrity_available_method_name = nullptr;
|
||||
GetStringFn get_integrity_token_method_name = nullptr;
|
||||
GetStringFn get_support_key = nullptr;
|
||||
GetStringFn get_token_key = nullptr;
|
||||
GetStringFn get_result_key = nullptr;
|
||||
void (*set_request_handler_raw)(JNIEnv*, jobject, jstring, jstring,
|
||||
jobject) = nullptr;
|
||||
void (*clear_request_handler)(JNIEnv*, jobject, jstring, jstring) = nullptr;
|
||||
|
||||
bool complete() const {
|
||||
return get_protocol_name && get_device_integrity_available_method_name &&
|
||||
get_integrity_token_method_name && get_support_key &&
|
||||
get_token_key && get_result_key && set_request_handler_raw &&
|
||||
clear_request_handler;
|
||||
}
|
||||
};
|
||||
|
||||
struct RobloxAccountProtocolObjects {
|
||||
jobject message_bus = nullptr;
|
||||
void* context = nullptr;
|
||||
jobject (*create_request_handler)(void*, std::shared_ptr<void>,
|
||||
std::string (*)(void*, JNIEnv*,
|
||||
jstring)) = nullptr;
|
||||
void (*clear_request_handler)(void*, jobject) = nullptr;
|
||||
|
||||
bool complete() const {
|
||||
return message_bus && context && create_request_handler &&
|
||||
clear_request_handler;
|
||||
}
|
||||
};
|
||||
|
||||
// Answers AccountProtocol device-integrity requests for a host that cannot
|
||||
// produce Play Integrity tokens. No integrity token is ever produced.
|
||||
//
|
||||
// DeviceIntegrityAvailable reports no support. The APK handler always reports
|
||||
// support, so this answer differs from Android: it tells Roblox's challenge
|
||||
// flow up front that no token can come, instead of letting it request one.
|
||||
//
|
||||
// GetIntegrityToken returns at once with an empty token and
|
||||
// TOKEN_PROVIDER_UNINITIALIZED, the APK's answer when its Play token provider
|
||||
// never initialized. The APK answers INVALID_NONCE for a request without a
|
||||
// requestHash; this bridge never inspects the request, so it cannot.
|
||||
// LuaApp bounds each token request with its
|
||||
// DeviceIntegrityNativeTimeoutMilliseconds flag; an immediate answer keeps a
|
||||
// login challenge from sitting out that bound.
|
||||
class RobloxAccountBridge final {
|
||||
public:
|
||||
RobloxAccountBridge(JniEnvironmentProvider environment,
|
||||
RobloxAccountProtocolSymbols symbols,
|
||||
RobloxAccountProtocolObjects objects);
|
||||
~RobloxAccountBridge();
|
||||
RobloxAccountBridge(const RobloxAccountBridge&) = delete;
|
||||
RobloxAccountBridge& operator=(const RobloxAccountBridge&) = delete;
|
||||
|
||||
Status Initialize();
|
||||
Status Shutdown();
|
||||
|
||||
private:
|
||||
struct State;
|
||||
Status ShutdownLocked();
|
||||
|
||||
const JniEnvironmentProvider environment_;
|
||||
const RobloxAccountProtocolSymbols symbols_;
|
||||
const RobloxAccountProtocolObjects objects_;
|
||||
// Serializes lifecycle only. Native dispatch never holds this mutex.
|
||||
std::mutex lifecycle_mutex_;
|
||||
std::shared_ptr<State> state_;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace mocktail
|
||||
|
||||
#endif // MOCKTAIL_RUNTIME_ROBLOX_ACCOUNT_BRIDGE_H_
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_ROBLOX_CALL_PROTOCOL_BRIDGE_H_
|
||||
#define MOCKTAIL_RUNTIME_ROBLOX_CALL_PROTOCOL_BRIDGE_H_
|
||||
|
||||
#include "runtime/roblox_message_bus_request_bridge.h"
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
|
||||
// In-experience CoreScripts query the app's cross-experience call state before
|
||||
// initializing voice. Mocktail does not start or accept cross-experience calls,
|
||||
// so that state is Idle. This query neither joins voice nor opens a microphone.
|
||||
class RobloxCallProtocolBridge final {
|
||||
public:
|
||||
RobloxCallProtocolBridge(JniEnvironmentProvider environment,
|
||||
RobloxMessageBusSymbols symbols,
|
||||
RobloxMessageBusObjects objects);
|
||||
Status Initialize();
|
||||
Status Shutdown();
|
||||
|
||||
private:
|
||||
RobloxMessageBusRequestBridge bridge_;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace mocktail
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
@@ -14,9 +15,11 @@
|
||||
#include "mocktail/status.h"
|
||||
#include "runtime/owned_pthread.h"
|
||||
#include "runtime/roblox_browser_service_bridge.h"
|
||||
#include "runtime/roblox_call_protocol_bridge.h"
|
||||
#include "runtime/roblox_experience_launch_bridge.h"
|
||||
#include "runtime/roblox_experience_presence.h"
|
||||
#include "runtime/roblox_fresh_game_launch_controller.h"
|
||||
#include "runtime/roblox_account_bridge.h"
|
||||
#include "runtime/roblox_permissions_bridge.h"
|
||||
#include "runtime/roblox_web_view_bridge.h"
|
||||
#include "runtime/webview_roblox_cookie.h"
|
||||
@@ -95,7 +98,9 @@ struct RobloxExperienceSurfaceProvider {
|
||||
void* context = nullptr;
|
||||
GameSurface (*snapshot)(void* context) = nullptr;
|
||||
|
||||
bool valid() const { return snapshot != nullptr; }
|
||||
bool valid() const {
|
||||
return snapshot != nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
// Production composition for the APK platform protocols and ExperienceProtocol
|
||||
@@ -120,7 +125,8 @@ class RobloxExperienceComposition final {
|
||||
RobloxExperienceSurfaceProvider surface_provider = {},
|
||||
RobloxExperiencePresenceObserver presence_observer = {},
|
||||
bool clear_persisted_web_view_cookie = false,
|
||||
bool microphone_enabled = false);
|
||||
bool microphone_enabled = false,
|
||||
RobloxAccountProtocolSymbols account_symbols = {});
|
||||
~RobloxExperienceComposition();
|
||||
|
||||
RobloxExperienceComposition(const RobloxExperienceComposition&) = delete;
|
||||
@@ -162,6 +168,7 @@ class RobloxExperienceComposition final {
|
||||
bool visible = true;
|
||||
bool back_navigation_disabled = false;
|
||||
bool show_domain_as_title = false;
|
||||
bool close_when_challenge_solved = false;
|
||||
};
|
||||
|
||||
static Status DispatchLaunch(void* context,
|
||||
@@ -201,8 +208,11 @@ class RobloxExperienceComposition final {
|
||||
const WebSurfacePresentation& presentation);
|
||||
// WebViewProtocol and BrowserService are two logical transports over the
|
||||
// APK's single physical WebView container. Either protocol may close or
|
||||
// mutate the surface that the other one opened.
|
||||
Status CloseWebSurface();
|
||||
// mutate the surface that the other one opened. A nonzero
|
||||
// expected_logical_generation closes only that surface.
|
||||
Status CloseWebSurface(uint64_t expected_logical_generation = 0);
|
||||
// Closes a solved challenge that Roblox left open past its grace period.
|
||||
Status CloseUnclaimedSolvedChallenge();
|
||||
void HandleWebSurfaceExit(uint64_t process_generation);
|
||||
Status Dispatch(const RobloxExperienceLaunchRequest& request);
|
||||
Status PromoteAuthenticatedSession();
|
||||
@@ -229,6 +239,7 @@ class RobloxExperienceComposition final {
|
||||
const RobloxWebViewMessageBusSymbols web_view_symbols_;
|
||||
const RobloxBrowserServiceSymbols browser_service_symbols_;
|
||||
const RobloxPermissionsMessageBusSymbols permissions_symbols_;
|
||||
const RobloxAccountProtocolSymbols account_symbols_;
|
||||
const bool microphone_enabled_;
|
||||
const RobloxGameSessionSymbols game_symbols_;
|
||||
const RobloxExperienceJniFactory jni_factory_;
|
||||
@@ -248,6 +259,9 @@ class RobloxExperienceComposition final {
|
||||
std::unique_ptr<RobloxWebViewBridge> web_view_bridge_;
|
||||
std::unique_ptr<RobloxBrowserServiceBridge> browser_service_bridge_;
|
||||
std::unique_ptr<RobloxPermissionsBridge> permissions_bridge_;
|
||||
std::unique_ptr<RobloxCallProtocolBridge> call_protocol_bridge_;
|
||||
// Optional: a payload without the AccountProtocol entrypoints still starts.
|
||||
std::unique_ptr<RobloxAccountBridge> account_bridge_;
|
||||
std::shared_ptr<WebViewHelperProcess> web_surface_process_;
|
||||
std::shared_ptr<WebSurfaceExitTarget> web_surface_exit_target_;
|
||||
std::shared_ptr<LifecycleTarget> lifecycle_target_;
|
||||
@@ -257,6 +271,13 @@ class RobloxExperienceComposition final {
|
||||
uint64_t web_surface_logical_generation_ = 0;
|
||||
uint64_t next_web_surface_process_generation_ = 1;
|
||||
uint64_t next_web_surface_logical_generation_ = 1;
|
||||
// The current surface closes as soon as its solved challenge is forwarded.
|
||||
bool web_surface_close_when_challenge_solved_ = false;
|
||||
// Set when a solved challenge is forwarded; applies only to that logical
|
||||
// surface generation.
|
||||
std::optional<std::chrono::steady_clock::time_point>
|
||||
solved_challenge_close_deadline_;
|
||||
uint64_t solved_challenge_logical_generation_ = 0;
|
||||
SecureWebViewRobloxCookie web_view_cookie_;
|
||||
std::string web_view_cookie_initialization_error_;
|
||||
bool web_view_cookie_synchronized_ = false;
|
||||
|
||||
@@ -40,9 +40,10 @@ struct AndroidKeyMapping {
|
||||
// through with an ABI-incompatible numeric value.
|
||||
AndroidKeyMapping MapSdlKeyToAndroid(uint32_t sdl_scancode, uint32_t sdl_key = 0);
|
||||
|
||||
// Mirrors the APK's MotionEvent.getActionButton() - 1 conversion. SDL button
|
||||
// numbers are not numerically compatible with Android button bit values.
|
||||
int32_t MapSdlMouseButtonToAndroid(uint8_t sdl_button);
|
||||
// Translates SDL button numbers to the nativePassMouseButton argument.
|
||||
// The first three are Roblox's zero-based MouseButton1/2/3 indices, not Android
|
||||
// MotionEvent button bits.
|
||||
int32_t MapSdlMouseButtonToRoblox(uint8_t sdl_button);
|
||||
|
||||
int32_t MapSdlGamepadButtonToAndroid(uint8_t sdl_button);
|
||||
int32_t RobloxGamepadType(platform::GamepadFamily family);
|
||||
|
||||
@@ -19,6 +19,13 @@ inline constexpr std::size_t kMaximumRobloxLaunchUriBytes = 64 * 1024;
|
||||
Status ParseRobloxLaunchUri(std::string_view uri,
|
||||
RobloxExperienceLaunchRequest* request);
|
||||
|
||||
// Converts a WebView launchGame command
|
||||
// ({"functionName":"launchGame","params":{"request":{...}}}) into the same
|
||||
// contract. Returns kUnsupported for other commands and kInvalidArgument for
|
||||
// a malformed launchGame request.
|
||||
Status ParseRobloxWebViewLaunchGame(std::string_view command,
|
||||
RobloxExperienceLaunchRequest* request);
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace mocktail
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_ROBLOX_MESSAGE_BUS_REQUEST_BRIDGE_H_
|
||||
#define MOCKTAIL_RUNTIME_ROBLOX_MESSAGE_BUS_REQUEST_BRIDGE_H_
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mocktail/status.h"
|
||||
#include "runtime/roblox_game_session_native_adapter.h"
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
struct RobloxMessageBusSymbols {
|
||||
jobject (*subscribe_request)(JNIEnv*, jobject, jstring, jstring, jobject,
|
||||
jboolean) = nullptr;
|
||||
void (*delete_connection)(JNIEnv*, jobject, jlong) = nullptr;
|
||||
void (*publish_response)(JNIEnv*, jobject, jstring, jstring, jstring, jint,
|
||||
jstring) = nullptr;
|
||||
void (*set_async_handler)(JNIEnv*, jobject, jstring, jstring,
|
||||
jobject) = nullptr;
|
||||
void (*clear_handler)(JNIEnv*, jobject, jstring, jstring) = nullptr;
|
||||
void (*call_response_handler)(JNIEnv*, jobject, jstring, jstring) = nullptr;
|
||||
|
||||
bool complete() const {
|
||||
return subscribe_request && delete_connection && publish_response &&
|
||||
set_async_handler && clear_handler && call_response_handler;
|
||||
}
|
||||
};
|
||||
|
||||
struct RobloxMessageBusObjects {
|
||||
jobject message_bus = nullptr;
|
||||
void* context = nullptr;
|
||||
jobject (*create_raw_callback)(void*, std::shared_ptr<void>,
|
||||
void (*)(void*, JNIEnv*, jstring)) = nullptr;
|
||||
void (*clear_raw_callback)(void*, jobject) = nullptr;
|
||||
jobject (*create_async_handler)(void*, std::shared_ptr<void>,
|
||||
void (*)(void*, JNIEnv*, jstring,
|
||||
jstring)) = nullptr;
|
||||
void (*clear_async_handler)(void*, jobject) = nullptr;
|
||||
|
||||
bool complete() const {
|
||||
return message_bus && context && create_raw_callback &&
|
||||
clear_raw_callback && create_async_handler && clear_async_handler;
|
||||
}
|
||||
};
|
||||
|
||||
struct RobloxMessageBusReply {
|
||||
std::string json;
|
||||
jint code = 0;
|
||||
const char* outcome = "ok";
|
||||
};
|
||||
|
||||
// Owns both legacy subscriptions and correlated async request handlers.
|
||||
// A policy receives only a request's method index and JNI-local payload.
|
||||
class RobloxMessageBusRequestBridge final {
|
||||
public:
|
||||
using Handler =
|
||||
std::function<RobloxMessageBusReply(JNIEnv*, jstring, std::size_t)>;
|
||||
RobloxMessageBusRequestBridge(JniEnvironmentProvider environment,
|
||||
RobloxMessageBusSymbols symbols,
|
||||
RobloxMessageBusObjects objects,
|
||||
std::string protocol,
|
||||
std::vector<std::string> methods,
|
||||
Handler handler);
|
||||
~RobloxMessageBusRequestBridge();
|
||||
Status Initialize();
|
||||
Status Shutdown();
|
||||
|
||||
private:
|
||||
struct State;
|
||||
Status ShutdownLocked();
|
||||
const JniEnvironmentProvider environment_;
|
||||
const RobloxMessageBusSymbols symbols_;
|
||||
const RobloxMessageBusObjects objects_;
|
||||
const std::string protocol_name_;
|
||||
const std::vector<std::string> methods_;
|
||||
const Handler handler_;
|
||||
std::mutex lifecycle_mutex_;
|
||||
std::shared_ptr<State> state_;
|
||||
};
|
||||
} // namespace runtime
|
||||
} // namespace mocktail
|
||||
#endif
|
||||
@@ -1,58 +1,12 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_ROBLOX_PERMISSIONS_BRIDGE_H_
|
||||
#define MOCKTAIL_RUNTIME_ROBLOX_PERMISSIONS_BRIDGE_H_
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "mocktail/status.h"
|
||||
#include "runtime/roblox_game_session_native_adapter.h"
|
||||
#include "runtime/roblox_message_bus_request_bridge.h"
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
using RobloxPermissionsMessageBusSymbols = RobloxMessageBusSymbols;
|
||||
using RobloxPermissionsMessageBusObjects = RobloxMessageBusObjects;
|
||||
|
||||
// Exact MessageBus JNI entrypoints used by the APK PermissionsProtocol.
|
||||
struct RobloxPermissionsMessageBusSymbols {
|
||||
jobject (*subscribe_request)(JNIEnv*, jobject, jstring, jstring, jobject,
|
||||
jboolean) = nullptr;
|
||||
void (*delete_connection)(JNIEnv*, jobject, jlong) = nullptr;
|
||||
void (*publish_response)(JNIEnv*, jobject, jstring, jstring, jstring, jint,
|
||||
jstring) = nullptr;
|
||||
void (*set_async_handler)(JNIEnv*, jobject, jstring, jstring,
|
||||
jobject) = nullptr;
|
||||
void (*clear_handler)(JNIEnv*, jobject, jstring, jstring) = nullptr;
|
||||
void (*call_response_handler)(JNIEnv*, jobject, jstring, jstring) = nullptr;
|
||||
|
||||
bool complete() const {
|
||||
return subscribe_request && delete_connection && publish_response &&
|
||||
set_async_handler && clear_handler && call_response_handler;
|
||||
}
|
||||
};
|
||||
|
||||
struct RobloxPermissionsMessageBusObjects {
|
||||
jobject message_bus = nullptr;
|
||||
void* context = nullptr;
|
||||
jobject (*create_raw_callback)(void*, std::shared_ptr<void>,
|
||||
void (*)(void*, JNIEnv*, jstring)) = nullptr;
|
||||
void (*clear_raw_callback)(void*, jobject) = nullptr;
|
||||
jobject (*create_async_handler)(void*, std::shared_ptr<void>,
|
||||
void (*)(void*, JNIEnv*, jstring,
|
||||
jstring)) = nullptr;
|
||||
void (*clear_async_handler)(void*, jobject) = nullptr;
|
||||
|
||||
bool complete() const {
|
||||
return message_bus && context && create_raw_callback &&
|
||||
clear_raw_callback && create_async_handler && clear_async_handler;
|
||||
}
|
||||
};
|
||||
|
||||
// Installs both legacy protocol subscriptions and correlated async handlers
|
||||
// before native bootstrap. MICROPHONE_ACCESS follows host capture
|
||||
// configuration; LOCAL_NETWORK needs no extra runtime permission, matching the
|
||||
// Android APK. No query/request opens an audio device, enables a disabled
|
||||
// microphone, or changes Roblox account eligibility. Other capabilities remain
|
||||
// unsupported.
|
||||
class RobloxPermissionsBridge final {
|
||||
public:
|
||||
RobloxPermissionsBridge(JniEnvironmentProvider environment,
|
||||
@@ -60,26 +14,12 @@ class RobloxPermissionsBridge final {
|
||||
RobloxPermissionsMessageBusObjects objects,
|
||||
bool microphone_enabled);
|
||||
~RobloxPermissionsBridge();
|
||||
RobloxPermissionsBridge(const RobloxPermissionsBridge&) = delete;
|
||||
RobloxPermissionsBridge& operator=(const RobloxPermissionsBridge&) = delete;
|
||||
|
||||
Status Initialize();
|
||||
Status Shutdown();
|
||||
|
||||
private:
|
||||
struct State;
|
||||
Status ShutdownLocked();
|
||||
|
||||
const JniEnvironmentProvider environment_;
|
||||
const RobloxPermissionsMessageBusSymbols symbols_;
|
||||
const RobloxPermissionsMessageBusObjects objects_;
|
||||
const bool microphone_enabled_;
|
||||
// Serializes lifecycle only. Native dispatch never holds this mutex.
|
||||
std::mutex lifecycle_mutex_;
|
||||
std::shared_ptr<State> state_;
|
||||
std::unique_ptr<RobloxMessageBusRequestBridge> bridge_;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace mocktail
|
||||
|
||||
#endif // MOCKTAIL_RUNTIME_ROBLOX_PERMISSIONS_BRIDGE_H_
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_ROBLOX_PLATFORM_WEB_SYMBOLS_H_
|
||||
#define MOCKTAIL_RUNTIME_ROBLOX_PLATFORM_WEB_SYMBOLS_H_
|
||||
|
||||
#include "runtime/roblox_account_bridge.h"
|
||||
#include "runtime/roblox_browser_service_bridge.h"
|
||||
#include "runtime/roblox_permissions_bridge.h"
|
||||
#include "runtime/roblox_web_view_bridge.h"
|
||||
@@ -15,6 +16,8 @@ struct RobloxPlatformWebSymbols {
|
||||
RobloxWebViewMessageBusSymbols web_view;
|
||||
RobloxBrowserServiceSymbols browser_service;
|
||||
RobloxPermissionsMessageBusSymbols permissions;
|
||||
// Optional and excluded from complete(); see RobloxExperienceComposition.
|
||||
RobloxAccountProtocolSymbols account;
|
||||
|
||||
bool complete() const {
|
||||
return web_view.complete() && browser_service.complete() &&
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef MOCKTAIL_RUNTIME_ROBLOX_PRESENCE_RESOLVER_H_
|
||||
#define MOCKTAIL_RUNTIME_ROBLOX_PRESENCE_RESOLVER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "mocktail/status.h"
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
|
||||
struct ResolvedFollowUserPlace {
|
||||
int64_t place_id = 0;
|
||||
std::string game_instance_id; // Roblox's "gameId" for the running session.
|
||||
};
|
||||
|
||||
// Reads the session cookie mocktail already persists at
|
||||
// ~/.local/share/mocktail/auth/roblox.cookie (or $XDG_DATA_HOME
|
||||
// equivalent). Returns an empty string if no session is stored.
|
||||
std::string ReadStoredRoblosecurityCookie();
|
||||
|
||||
// Calls Roblox's presence API to find what place/instance a user is
|
||||
// currently in. `auth_cookie` is the runtime's already-authenticated
|
||||
// .ROBLOSECURITY (or equivalent bearer token) — this function performs no
|
||||
// authentication of its own and requires the runtime's validated session.
|
||||
//
|
||||
// Returns an error if the user is offline, has presence hidden, or is not
|
||||
// in a joinable experience (e.g. in Studio, or privacy settings block it).
|
||||
Status ResolveFollowUserPlace(int64_t user_id, const std::string& auth_cookie,
|
||||
ResolvedFollowUserPlace* out);
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace mocktail
|
||||
|
||||
#endif // MOCKTAIL_RUNTIME_ROBLOX_PRESENCE_RESOLVER_H_
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
@@ -10,8 +11,10 @@ namespace runtime {
|
||||
// Android's RbxKeyboard resolves the Roblox Font enum through
|
||||
// assets/android/fonts/font-mappings.json. The selected file lives below
|
||||
// assets/content/fonts while legacy SourceSansPro faces live in assets/fonts.
|
||||
// Emoji come from the color fonts Roblox ships next to the mapped faces.
|
||||
struct RobloxTextFontSelection {
|
||||
std::string primary_file;
|
||||
std::vector<std::string> emoji_files;
|
||||
float size_scale = 0.795F;
|
||||
bool exact_mapping = false;
|
||||
};
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "mocktail/status.h"
|
||||
#include "runtime/roblox_text_display_state.h"
|
||||
|
||||
struct TTF_Font;
|
||||
|
||||
namespace mocktail {
|
||||
namespace runtime {
|
||||
|
||||
@@ -39,6 +41,8 @@ class RobloxTextSurfaceOverlay final {
|
||||
const RobloxTextDisplayUpdate& update);
|
||||
void ApplyUpdate(const RobloxTextDisplayUpdate& update);
|
||||
Status RasterizeLocked();
|
||||
Status OpenFontsLocked(std::int32_t font, float point_size);
|
||||
void CloseFontsLocked();
|
||||
void ClearFrameLocked();
|
||||
void RecordFailureLocked(Status status);
|
||||
|
||||
@@ -46,10 +50,14 @@ class RobloxTextSurfaceOverlay final {
|
||||
RobloxTextDisplayState state_;
|
||||
RobloxTextOverlayViewport viewport_;
|
||||
std::vector<std::uint8_t> rgba_;
|
||||
std::vector<TTF_Font*> fonts_;
|
||||
std::int32_t fonts_font_ = 0;
|
||||
float fonts_point_size_ = 0.0F;
|
||||
std::uint64_t state_revision_ = 0;
|
||||
std::uint64_t raster_revision_ = 0;
|
||||
Status failure_;
|
||||
bool initialized_ = false;
|
||||
bool ttf_initialized_ = false;
|
||||
bool failure_logged_ = false;
|
||||
bool ready_logged_ = false;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include "mocktail/status.h"
|
||||
#include "runtime/roblox_game_session_native_adapter.h"
|
||||
@@ -30,6 +32,9 @@ inline constexpr char kRobloxOpenCaptchaViewNotification[] =
|
||||
"OPEN_CAPTCHA_VIEW";
|
||||
inline constexpr char kRobloxViewProfileNotification[] = "VIEW_PROFILE";
|
||||
inline constexpr char kRobloxPurchaseRobuxNotification[] = "PURCHASE_ROBUX";
|
||||
// Sent with a decimal user id when the app asks for a chat with that user.
|
||||
inline constexpr char kRobloxLaunchConversationNotification[] =
|
||||
"LAUNCH_CONVERSATION";
|
||||
|
||||
// Owned subset of WebViewProtocol's openWindow payload. The URL is copied
|
||||
// before the MessageBus RawCallback returns, so no JNI local reference escapes.
|
||||
@@ -42,6 +47,10 @@ struct RobloxWebViewOpenRequest {
|
||||
std::optional<bool> show_domain_as_title;
|
||||
std::optional<bool> back_button_visible;
|
||||
std::optional<bool> hide_header;
|
||||
// Set by the bridge, never parsed. The host closes an OPEN_CAPTCHA_VIEW
|
||||
// window once its solved captcha has been forwarded, as Android's captcha
|
||||
// activity finishes itself on success.
|
||||
bool close_when_challenge_solved = false;
|
||||
};
|
||||
|
||||
// WebViewProtocol.mutateWindow is a partial update. Field absence must remain
|
||||
@@ -61,6 +70,9 @@ Status ParseRobloxWebViewMutationJson(const std::string& json,
|
||||
RobloxWebViewMutationRequest* request);
|
||||
Status ParseRobloxCaptchaOpenJson(const std::string& json,
|
||||
RobloxWebViewOpenRequest* request);
|
||||
// True for a page's Navigation.navigateToFeature command reporting a solved
|
||||
// verification (see webview::IsRobloxChallengeSolvedFeature).
|
||||
bool IsRobloxWebViewChallengeSuccess(std::string_view command);
|
||||
Status ParseRobloxProfileViewUrl(const std::string& url,
|
||||
RobloxWebViewOpenRequest* request);
|
||||
Status ParseRobloxPurchaseRobuxNotification(const std::string& json,
|
||||
@@ -106,8 +118,43 @@ using PublishWebViewRawFn = void (*)(JNIEnv *, jobject, jstring, jstring);
|
||||
using BroadcastWebViewDataModelFocusFn = void (*)(JNIEnv *, jclass, jstring,
|
||||
jstring, jstring);
|
||||
using SignalWebViewJavascriptCallbackFn = void (*)(JNIEnv*, jclass, jstring);
|
||||
// NativeGLInterface.nativeAppBridgeV2SendAppEventOnGameLoaded(namespace,
|
||||
// detail, detailType).
|
||||
using SendRobloxAppEventOnGameLoadedFn = void (*)(JNIEnv*, jclass, jstring,
|
||||
jstring, jstring);
|
||||
// NativeGLInterface.nativeAppBridgeV2SendAppEventOnAppReady(namespace, detail,
|
||||
// detailType, appName). The engine holds the event until appName is ready.
|
||||
using SendRobloxAppEventOnAppReadyFn = void (*)(JNIEnv*, jclass, jstring,
|
||||
jstring, jstring, jstring);
|
||||
using UpdateRobloxCookieSetHandlerFn =
|
||||
void (*)(JNIEnv*, jobject, jobject);
|
||||
// Roblox's counted handle to its Subsystem<IWebViewProtocol>. The protocol,
|
||||
// and its handleJavascriptCallback subscriber, exist only while a handle is
|
||||
// held. Roblox's handle type is not trivially destructible, so its getter
|
||||
// returns it through the caller-supplied result slot (rdi on x86-64, x8 on
|
||||
// AArch64). The user-provided destructor gives this type the same calling
|
||||
// convention. It does not release the handle.
|
||||
class RobloxWebViewProtocolHandle final {
|
||||
public:
|
||||
RobloxWebViewProtocolHandle() = default;
|
||||
explicit RobloxWebViewProtocolHandle(void* holder) : holder_(holder) {}
|
||||
RobloxWebViewProtocolHandle(const RobloxWebViewProtocolHandle&) = default;
|
||||
RobloxWebViewProtocolHandle& operator=(const RobloxWebViewProtocolHandle&) =
|
||||
default;
|
||||
~RobloxWebViewProtocolHandle() {}
|
||||
|
||||
void* holder() const { return holder_; }
|
||||
|
||||
private:
|
||||
void* holder_ = nullptr;
|
||||
};
|
||||
static_assert(sizeof(RobloxWebViewProtocolHandle) == sizeof(void*));
|
||||
static_assert(!std::is_trivially_destructible_v<RobloxWebViewProtocolHandle>);
|
||||
|
||||
// Roblox's Subsystem<IWebViewProtocol> getter. It is not exported; the
|
||||
// resolver finds it through the first call in
|
||||
// WebViewProtocol.initializeAndroidWebViewProtocol.
|
||||
using AcquireWebViewProtocolFn = RobloxWebViewProtocolHandle (*)();
|
||||
|
||||
struct RobloxWebViewMessageBusSymbols {
|
||||
GetWebViewOpenWindowIdFn get_open_window_id = nullptr;
|
||||
@@ -129,6 +176,11 @@ struct RobloxWebViewMessageBusSymbols {
|
||||
GetWebViewCloseWindowIdFn get_close_window_id = nullptr;
|
||||
SignalWebViewJavascriptCallbackFn signal_javascript_callback = nullptr;
|
||||
UpdateRobloxCookieSetHandlerFn update_cookie_set_handler = nullptr;
|
||||
// Optional: found by code contract, not by symbol name.
|
||||
AcquireWebViewProtocolFn acquire_web_view_protocol = nullptr;
|
||||
// Optional: without them LAUNCH_CONVERSATION is reported as unavailable.
|
||||
SendRobloxAppEventOnGameLoadedFn send_app_event_on_game_loaded = nullptr;
|
||||
SendRobloxAppEventOnAppReadyFn send_app_event_on_app_ready = nullptr;
|
||||
|
||||
bool complete() const {
|
||||
return get_open_window_id != nullptr &&
|
||||
@@ -232,11 +284,14 @@ private:
|
||||
kDataModelUnfocused,
|
||||
kDataModelFocused,
|
||||
kMessageBusWindowClose,
|
||||
kStartConversationWithUser,
|
||||
};
|
||||
|
||||
struct PendingHostWindowEvent {
|
||||
HostWindowEventType type = HostWindowEventType::kDataModelUnfocused;
|
||||
uint64_t generation = 0;
|
||||
// Decimal user id of a kStartConversationWithUser event.
|
||||
std::string user_id;
|
||||
};
|
||||
|
||||
Status CheckJniException(JNIEnv *env, const char *operation) const;
|
||||
@@ -245,6 +300,8 @@ private:
|
||||
Status DispatchOpenRequest(RobloxWebViewOpenRequest request,
|
||||
OpenSource source);
|
||||
void QueueHostWindowEvent(HostWindowEventType type, uint64_t generation);
|
||||
void QueueStartConversation(std::string user_id);
|
||||
Status SendStartConversationEvents(JNIEnv* env, const std::string& user_id);
|
||||
Status BeginDispatch();
|
||||
void EndDispatch();
|
||||
static void RawMessageCallback(void *context, JNIEnv *env, jstring message);
|
||||
@@ -287,6 +344,10 @@ private:
|
||||
std::array<std::shared_ptr<RawCallbackTarget>, kSubscriptionCount>
|
||||
raw_callback_targets_{};
|
||||
std::shared_ptr<HostWindowCloseTarget> host_window_close_target_;
|
||||
// The reference this counts is kept for the process lifetime, as Roblox's
|
||||
// Android app start keeps its own. Neither Shutdown nor destruction
|
||||
// releases it.
|
||||
RobloxWebViewProtocolHandle web_view_protocol_handle_;
|
||||
std::size_t in_flight_dispatches_ = 0;
|
||||
bool initializing_ = false;
|
||||
bool shutting_down_ = false;
|
||||
|
||||
@@ -14,7 +14,7 @@ struct ActivePayloadPaths {
|
||||
std::filesystem::path root;
|
||||
std::filesystem::path roblox_library;
|
||||
std::filesystem::path base_apk;
|
||||
std::filesystem::path x86_64_split_apk;
|
||||
std::filesystem::path arch_split_apk;
|
||||
std::filesystem::path assets_content;
|
||||
std::filesystem::path compatibility_manifest;
|
||||
std::filesystem::path host_abi_profile;
|
||||
@@ -67,6 +67,9 @@ class RuntimePaths {
|
||||
return active_payload_manifest_;
|
||||
}
|
||||
const std::filesystem::path& cookie_file() const { return cookie_file_; }
|
||||
const std::filesystem::path& asset_overlay_dir() const {
|
||||
return asset_overlay_dir_;
|
||||
}
|
||||
bool use_real_sober_paths() const { return use_real_sober_paths_; }
|
||||
|
||||
std::filesystem::path DefaultAssetPath() const;
|
||||
@@ -99,6 +102,7 @@ class RuntimePaths {
|
||||
std::filesystem::path config_file_;
|
||||
std::filesystem::path active_payload_manifest_;
|
||||
std::filesystem::path cookie_file_;
|
||||
std::filesystem::path asset_overlay_dir_;
|
||||
bool use_real_sober_paths_ = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ struct HostAbiDerivationOptions {
|
||||
std::filesystem::path reference_library;
|
||||
std::filesystem::path reference_profile;
|
||||
std::vector<std::filesystem::path> reference_compatibility_manifests;
|
||||
// Optional libroblox.so of another build that the compatibility manifests
|
||||
// describe. It supplies the FMOD output-device anchors when the manifests
|
||||
// have none for the reference build.
|
||||
std::filesystem::path runtime_fallback_library;
|
||||
std::filesystem::path candidate_payload_directory;
|
||||
std::filesystem::path output_directory;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -33,11 +34,18 @@ struct PayloadGarbageResult {
|
||||
explicit operator bool() const { return error.empty(); }
|
||||
};
|
||||
|
||||
// Optional per-store fault hook for atomic manifest writes. Returning true
|
||||
// makes the selected operation fail through its normal cleanup path.
|
||||
enum class ManifestWritePhase { kCreate, kWrite, kFileFsync, kRename };
|
||||
using ManifestWriteFault =
|
||||
std::function<bool(const std::filesystem::path&, ManifestWritePhase)>;
|
||||
|
||||
class PayloadStore final {
|
||||
public:
|
||||
PayloadStore(std::filesystem::path root,
|
||||
std::filesystem::path compatibility_manifest,
|
||||
std::filesystem::path runtime_binary = {});
|
||||
std::filesystem::path runtime_binary = {},
|
||||
ManifestWriteFault manifest_write_fault = {});
|
||||
|
||||
PayloadStoreResult Stage(const std::filesystem::path& prepared_payload);
|
||||
PayloadStoreResult Promote(std::string_view payload_id);
|
||||
@@ -60,6 +68,7 @@ class PayloadStore final {
|
||||
std::filesystem::path root_;
|
||||
std::filesystem::path compatibility_manifest_;
|
||||
std::filesystem::path runtime_binary_;
|
||||
ManifestWriteFault manifest_write_fault_;
|
||||
};
|
||||
|
||||
} // namespace mocktail::update
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#ifndef MOCKTAIL_UPDATE_READINESS_CANARY_H_
|
||||
#define MOCKTAIL_UPDATE_READINESS_CANARY_H_
|
||||
|
||||
#include <spawn.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -22,6 +25,12 @@ std::string_view CanaryGraphicsBackendName(CanaryGraphicsBackend backend);
|
||||
bool ParseCanaryGraphicsBackend(std::string_view name,
|
||||
CanaryGraphicsBackend* backend);
|
||||
|
||||
// Optional per-request replacement for the POSIX spawn operation.
|
||||
// It follows posix_spawn return/ownership semantics; empty uses posix_spawn.
|
||||
using CanarySpawn =
|
||||
std::function<int(pid_t*, const char*, const posix_spawn_file_actions_t*,
|
||||
const posix_spawnattr_t*, char* const[], char* const[])>;
|
||||
|
||||
struct CanaryOptions {
|
||||
std::filesystem::path runtime_binary;
|
||||
std::filesystem::path payload_directory;
|
||||
@@ -29,9 +38,9 @@ struct CanaryOptions {
|
||||
std::filesystem::path host_abi_profile;
|
||||
std::filesystem::path cache_root;
|
||||
std::filesystem::path state_root;
|
||||
CanaryGraphicsBackend graphics_backend =
|
||||
CanaryGraphicsBackend::kDirectVulkan;
|
||||
CanaryGraphicsBackend graphics_backend = CanaryGraphicsBackend::kDirectVulkan;
|
||||
int timeout_seconds = 150;
|
||||
CanarySpawn spawn;
|
||||
|
||||
bool probation_candidate() const { return !host_abi_profile.empty(); }
|
||||
};
|
||||
@@ -39,6 +48,8 @@ struct CanaryOptions {
|
||||
struct CanaryResult {
|
||||
std::filesystem::path log_path;
|
||||
int exit_code = -1;
|
||||
// Direct posix_spawn return code; zero when spawn was not attempted.
|
||||
int spawn_error = 0;
|
||||
std::string error;
|
||||
|
||||
explicit operator bool() const {
|
||||
|
||||
@@ -26,6 +26,8 @@ struct UpdatePaths {
|
||||
// build the single file happens to describe.
|
||||
std::filesystem::path host_abi_reference_profile;
|
||||
std::filesystem::path runtime_binary;
|
||||
// Optional packaging wrapper; runtime_binary identifies the actual ELF.
|
||||
std::filesystem::path runtime_launcher;
|
||||
};
|
||||
|
||||
struct UpdateRequest {
|
||||
@@ -38,6 +40,7 @@ struct UpdateRequest {
|
||||
CanaryGraphicsBackend canary_graphics_backend =
|
||||
CanaryGraphicsBackend::kDirectVulkan;
|
||||
int progress_fd = -1;
|
||||
CanarySpawn canary_spawn;
|
||||
};
|
||||
|
||||
struct UpdateResult {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef MOCKTAIL_WEBVIEW_ROBLOX_CHALLENGE_FEATURES_H_
|
||||
#define MOCKTAIL_WEBVIEW_ROBLOX_CHALLENGE_FEATURES_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace mocktail::webview {
|
||||
|
||||
// Navigation.navigateToFeature features a Roblox verification page sends when
|
||||
// the user has solved it. The captcha page sends CaptchaSuccess; the generic
|
||||
// challenge page (challenge/cdn/hybrid) sends challengeCompleted. The WebView
|
||||
// helper and the runtime both classify page events with this list.
|
||||
inline bool IsRobloxChallengeSolvedFeature(std::string_view feature) {
|
||||
return feature == "CaptchaSuccess" || feature == "challengeCompleted" ||
|
||||
feature == "ChallengeCompleted";
|
||||
}
|
||||
|
||||
} // namespace mocktail::webview
|
||||
|
||||
#endif // MOCKTAIL_WEBVIEW_ROBLOX_CHALLENGE_FEATURES_H_
|
||||
@@ -13,6 +13,11 @@ pre-commit:
|
||||
desktop-entry:
|
||||
glob: "*.desktop"
|
||||
run: desktop-file-validate {staged_files}
|
||||
changelog-width:
|
||||
glob: "CHANGELOG.md"
|
||||
run: >-
|
||||
git diff --cached -U0 -- CHANGELOG.md |
|
||||
awk '/^\+[^+]/ && length($0) > 111 { print "CHANGELOG.md: added line over 110 characters: " substr($0, 2); bad = 1 } END { exit bad }'
|
||||
|
||||
pre-push:
|
||||
commands:
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Allowed reduced aarch64 packages from pkgforge-dev/archlinux-pkgs-debloated.
|
||||
# The installer verifies the rolling release asset IDs and SHA256 digests.
|
||||
ffmpeg-mini-aarch64.pkg.tar.zst
|
||||
gdk-pixbuf2-mini-aarch64.pkg.tar.xz
|
||||
gtk4-mini-aarch64.pkg.tar.zst
|
||||
icu-mini-aarch64.pkg.tar.zst
|
||||
librsvg-mini-aarch64.pkg.tar.zst
|
||||
libxml2-mini-aarch64.pkg.tar.zst
|
||||
mesa-mini-aarch64.pkg.tar.zst
|
||||
opus-mini-aarch64.pkg.tar.zst
|
||||
@@ -7,6 +7,7 @@ MOCKTAIL_PORTABLE_MODE=standalone
|
||||
MOCKTAIL_RUNTIME_LIBRARY_DIR=${SHARUN_DIR}/lib/mocktail
|
||||
MOCKTAIL_BIN=${SHARUN_DIR}/bin/mocktail
|
||||
MOCKTAIL_UPDATE_CANARY_BIN=${SHARUN_DIR}/bin/mocktail
|
||||
MOCKTAIL_UPDATE_RUNTIME_BINARY=${SHARUN_DIR}/shared/bin/mocktail
|
||||
MOCKTAIL_UPDATE_HELPER=${SHARUN_DIR}/bin/mocktail_updater
|
||||
MOCKTAIL_WEBVIEW_HELPER=${SHARUN_DIR}/bin/mocktail_webview_helper
|
||||
MOCKTAIL_FAILURE_DIALOG_HELPER=${SHARUN_DIR}/bin/mocktail_failure_dialog
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# Maintainer: komaruworld <rtysus228@gmail.com>
|
||||
# Maintainer: vii <coderdayton14@gmail.com>
|
||||
|
||||
pkgname=mocktail
|
||||
pkgver=1.0.3
|
||||
pkgrel=2
|
||||
pkgname=nightcap
|
||||
pkgver=0.3.4
|
||||
pkgrel=1
|
||||
pkgdesc='Android x86-64 Roblox compatibility runtime for Linux'
|
||||
arch=('x86_64')
|
||||
url='https://github.com/komaruworld/mocktail'
|
||||
url='https://github.com/CoderDayton/nightcap'
|
||||
license=('Apache-2.0')
|
||||
provides=('mocktail')
|
||||
conflicts=('mocktail')
|
||||
depends=(
|
||||
'capstone'
|
||||
'curl'
|
||||
@@ -16,6 +18,7 @@ depends=(
|
||||
'libelf'
|
||||
'libglvnd'
|
||||
'libplacebo'
|
||||
'libpng'
|
||||
'libutf8proc'
|
||||
'libyaml'
|
||||
'minizip'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
pkgbase = mocktail-bin
|
||||
pkgbase = nightcap-bin
|
||||
pkgdesc = Android x86-64 Roblox compatibility runtime for Linux (prebuilt)
|
||||
pkgver = 1.0.4
|
||||
pkgver = 0.3.4
|
||||
pkgrel = 1
|
||||
url = https://github.com/komaruworld/mocktail
|
||||
url = https://github.com/CoderDayton/nightcap
|
||||
arch = x86_64
|
||||
license = Apache-2.0
|
||||
depends = capstone
|
||||
@@ -17,6 +17,7 @@ pkgbase = mocktail-bin
|
||||
depends = libelf
|
||||
depends = libglvnd
|
||||
depends = libplacebo
|
||||
depends = libpng
|
||||
depends = libsoup3
|
||||
depends = libutf8proc
|
||||
depends = libyaml
|
||||
@@ -29,12 +30,14 @@ pkgbase = mocktail-bin
|
||||
depends = zlib
|
||||
optdepends = gamemode: Feral GameMode integration
|
||||
provides = mocktail
|
||||
provides = nightcap
|
||||
conflicts = mocktail
|
||||
conflicts = mocktail-git
|
||||
noextract = mocktail-1.0.4-x86_64.pkg.tar.zst
|
||||
conflicts = nightcap
|
||||
conflicts = nightcap-git
|
||||
noextract = nightcap-0.3.4-1-x86_64.pkg.tar.zst
|
||||
options = !debug
|
||||
options = !strip
|
||||
source = mocktail-1.0.4-x86_64.pkg.tar.zst::https://github.com/komaruworld/mocktail/releases/download/1.0.4/mocktail-1.0.4-x86_64.pkg.tar.zst
|
||||
sha256sums = d5cc7216e88fd2889369e8eb7fba4276b2746c2b084dce566aaaa7505bc2ffb7
|
||||
source = nightcap-0.3.4-1-x86_64.pkg.tar.zst::https://github.com/CoderDayton/nightcap/releases/download/v0.3.4/nightcap-0.3.4-1-x86_64.pkg.tar.zst
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = mocktail-bin
|
||||
pkgname = nightcap-bin
|
||||
@@ -1,11 +1,11 @@
|
||||
# Maintainer: komaruworld <rtysus228 at gmail dot com>
|
||||
# Maintainer: vii <coderdayton14 at gmail dot com>
|
||||
|
||||
pkgname=mocktail-bin
|
||||
pkgver=1.0.4
|
||||
pkgname=nightcap-bin
|
||||
pkgver=0.3.4
|
||||
pkgrel=1
|
||||
pkgdesc='Android x86-64 Roblox compatibility runtime for Linux (prebuilt)'
|
||||
arch=('x86_64')
|
||||
url='https://github.com/komaruworld/mocktail'
|
||||
url='https://github.com/CoderDayton/nightcap'
|
||||
license=('Apache-2.0')
|
||||
depends=(
|
||||
'capstone'
|
||||
@@ -20,6 +20,7 @@ depends=(
|
||||
'libelf'
|
||||
'libglvnd'
|
||||
'libplacebo'
|
||||
'libpng'
|
||||
'libsoup3'
|
||||
'libutf8proc'
|
||||
'libyaml'
|
||||
@@ -32,17 +33,18 @@ depends=(
|
||||
'zlib'
|
||||
)
|
||||
optdepends=('gamemode: Feral GameMode integration')
|
||||
provides=('mocktail')
|
||||
conflicts=('mocktail' 'mocktail-git')
|
||||
provides=('mocktail' 'nightcap')
|
||||
conflicts=('mocktail' 'nightcap' 'nightcap-git')
|
||||
options=('!debug' '!strip')
|
||||
# Release asset names do not include the AUR package release.
|
||||
_archive="mocktail-${pkgver}-${CARCH}.pkg.tar.zst"
|
||||
source=("${_archive}::https://github.com/komaruworld/mocktail/releases/download/${pkgver}/${_archive}")
|
||||
# The release asset carries the pacman package release built by release.yml.
|
||||
_archive="nightcap-${pkgver}-1-${CARCH}.pkg.tar.zst"
|
||||
source=("${_archive}::https://github.com/CoderDayton/nightcap/releases/download/v${pkgver}/${_archive}")
|
||||
noextract=("${_archive}")
|
||||
sha256sums=('d5cc7216e88fd2889369e8eb7fba4276b2746c2b084dce566aaaa7505bc2ffb7')
|
||||
# Replace with the checksum published beside the release asset.
|
||||
sha256sums=('SKIP')
|
||||
|
||||
package() {
|
||||
bsdtar -xf "${srcdir}/${_archive}" -C "${pkgdir}" usr
|
||||
install -Dm644 "${pkgdir}/usr/share/licenses/mocktail/LICENSE" \
|
||||
install -Dm644 "${pkgdir}/usr/share/licenses/nightcap/LICENSE" \
|
||||
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
pkgbase = mocktail
|
||||
pkgbase = nightcap-git
|
||||
pkgdesc = Android x86-64 Roblox compatibility runtime for Linux
|
||||
pkgver = 1.0.4
|
||||
pkgver = 0.3.1.r0.g0000000
|
||||
pkgrel = 1
|
||||
url = https://github.com/komaruworld/mocktail
|
||||
url = https://github.com/CoderDayton/nightcap
|
||||
arch = x86_64
|
||||
license = Apache-2.0
|
||||
makedepends = cmake>=3.20
|
||||
@@ -24,6 +24,7 @@ pkgbase = mocktail
|
||||
depends = libelf
|
||||
depends = libglvnd
|
||||
depends = libplacebo
|
||||
depends = libpng
|
||||
depends = libsoup3
|
||||
depends = libutf8proc
|
||||
depends = libyaml
|
||||
@@ -35,11 +36,13 @@ pkgbase = mocktail
|
||||
depends = webkitgtk-6.0
|
||||
depends = zlib
|
||||
optdepends = gamemode: Feral GameMode integration
|
||||
conflicts = mocktail-bin
|
||||
conflicts = mocktail-git
|
||||
provides = mocktail
|
||||
provides = nightcap
|
||||
conflicts = mocktail
|
||||
conflicts = nightcap
|
||||
conflicts = nightcap-bin
|
||||
options = !debug
|
||||
options = !lto
|
||||
source = mocktail::git+https://github.com/komaruworld/mocktail.git#tag=1.0.4
|
||||
source = nightcap::git+https://github.com/CoderDayton/nightcap.git#branch=main
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = mocktail
|
||||
pkgname = nightcap-git
|
||||
@@ -1,11 +1,11 @@
|
||||
# Maintainer: komaruworld <rtysus228 at gmail dot com>
|
||||
# Maintainer: vii <coderdayton14 at gmail dot com>
|
||||
|
||||
pkgname=mocktail-git
|
||||
pkgver=1.0.2.r24.g9bdd737
|
||||
pkgname=nightcap-git
|
||||
pkgver=0.3.1.r0.g0000000
|
||||
pkgrel=1
|
||||
pkgdesc='Android x86-64 Roblox compatibility runtime for Linux'
|
||||
arch=('x86_64')
|
||||
url='https://github.com/komaruworld/mocktail'
|
||||
url='https://github.com/CoderDayton/nightcap'
|
||||
license=('Apache-2.0')
|
||||
depends=(
|
||||
'capstone'
|
||||
@@ -20,6 +20,7 @@ depends=(
|
||||
'libelf'
|
||||
'libglvnd'
|
||||
'libplacebo'
|
||||
'libpng'
|
||||
'libsoup3'
|
||||
'libutf8proc'
|
||||
'libyaml'
|
||||
@@ -41,31 +42,30 @@ makedepends=(
|
||||
'vulkan-headers'
|
||||
)
|
||||
optdepends=('gamemode: Feral GameMode integration')
|
||||
provides=('mocktail')
|
||||
conflicts=('mocktail' 'mocktail-bin')
|
||||
provides=('mocktail' 'nightcap')
|
||||
conflicts=('mocktail' 'nightcap' 'nightcap-bin')
|
||||
options=('!debug')
|
||||
source=(
|
||||
'mocktail::git+https://github.com/komaruworld/mocktail.git#branch=main'
|
||||
'nightcap::git+https://github.com/CoderDayton/nightcap.git#branch=main'
|
||||
)
|
||||
sha256sums=(
|
||||
'SKIP'
|
||||
)
|
||||
|
||||
pkgver() {
|
||||
cd mocktail
|
||||
cd nightcap
|
||||
|
||||
local version
|
||||
version="$(sed -n \
|
||||
's/^[[:space:]]*VERSION[[:space:]]\+\([0-9][0-9.]*\).*/\1/p' \
|
||||
CMakeLists.txt | head -n 1)"
|
||||
version="$(git describe --tags --abbrev=0 --match='v[0-9]*' 2>/dev/null)"
|
||||
version="${version#v}"
|
||||
printf '%s.r%s.g%s' \
|
||||
"${version}" \
|
||||
"${version:-0.0.0}" \
|
||||
"$(git rev-list --count HEAD)" \
|
||||
"$(git rev-parse --short=7 HEAD)"
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd mocktail
|
||||
cd nightcap
|
||||
|
||||
sed -i \
|
||||
's|add_subdirectory(third_party/Vulkan-Headers EXCLUDE_FROM_ALL)|find_package(VulkanHeaders CONFIG REQUIRED)|' \
|
||||
@@ -73,7 +73,7 @@ prepare() {
|
||||
}
|
||||
|
||||
build() {
|
||||
cmake -S mocktail -B build -G Ninja \
|
||||
cmake -S nightcap -B build -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
@@ -86,6 +86,6 @@ build() {
|
||||
|
||||
package() {
|
||||
DESTDIR="${pkgdir}" cmake --install build
|
||||
install -Dm644 mocktail/LICENSE \
|
||||
install -Dm644 nightcap/LICENSE \
|
||||
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
pkgbase = mocktail-git
|
||||
pkgbase = nightcap
|
||||
pkgdesc = Android x86-64 Roblox compatibility runtime for Linux
|
||||
pkgver = 1.0.2.r24.g9bdd737
|
||||
pkgver = 0.3.4
|
||||
pkgrel = 1
|
||||
url = https://github.com/komaruworld/mocktail
|
||||
url = https://github.com/CoderDayton/nightcap
|
||||
arch = x86_64
|
||||
license = Apache-2.0
|
||||
makedepends = cmake>=3.20
|
||||
@@ -24,6 +24,7 @@ pkgbase = mocktail-git
|
||||
depends = libelf
|
||||
depends = libglvnd
|
||||
depends = libplacebo
|
||||
depends = libpng
|
||||
depends = libsoup3
|
||||
depends = libutf8proc
|
||||
depends = libyaml
|
||||
@@ -37,9 +38,11 @@ pkgbase = mocktail-git
|
||||
optdepends = gamemode: Feral GameMode integration
|
||||
provides = mocktail
|
||||
conflicts = mocktail
|
||||
conflicts = mocktail-bin
|
||||
conflicts = nightcap-bin
|
||||
conflicts = nightcap-git
|
||||
options = !debug
|
||||
source = mocktail::git+https://github.com/komaruworld/mocktail.git#branch=main
|
||||
options = !lto
|
||||
source = nightcap::git+https://github.com/CoderDayton/nightcap.git#tag=v0.3.4
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = mocktail-git
|
||||
pkgname = nightcap
|
||||
@@ -1,11 +1,11 @@
|
||||
# Maintainer: komaruworld <rtysus228 at gmail dot com>
|
||||
# Maintainer: vii <coderdayton14 at gmail dot com>
|
||||
|
||||
pkgname=mocktail
|
||||
pkgver=1.0.4
|
||||
pkgname=nightcap
|
||||
pkgver=0.3.4
|
||||
pkgrel=1
|
||||
pkgdesc='Android x86-64 Roblox compatibility runtime for Linux'
|
||||
arch=('x86_64')
|
||||
url='https://github.com/komaruworld/mocktail'
|
||||
url='https://github.com/CoderDayton/nightcap'
|
||||
license=('Apache-2.0')
|
||||
depends=(
|
||||
'capstone'
|
||||
@@ -20,6 +20,7 @@ depends=(
|
||||
'libelf'
|
||||
'libglvnd'
|
||||
'libplacebo'
|
||||
'libpng'
|
||||
'libsoup3'
|
||||
'libutf8proc'
|
||||
'libyaml'
|
||||
@@ -41,17 +42,18 @@ makedepends=(
|
||||
'vulkan-headers'
|
||||
)
|
||||
optdepends=('gamemode: Feral GameMode integration')
|
||||
conflicts=('mocktail-bin' 'mocktail-git')
|
||||
provides=('mocktail')
|
||||
conflicts=('mocktail' 'nightcap-bin' 'nightcap-git')
|
||||
options=('!debug' '!lto')
|
||||
source=(
|
||||
"mocktail::git+https://github.com/komaruworld/mocktail.git#tag=${pkgver}"
|
||||
"nightcap::git+https://github.com/CoderDayton/nightcap.git#tag=v${pkgver}"
|
||||
)
|
||||
sha256sums=(
|
||||
'SKIP'
|
||||
)
|
||||
|
||||
prepare() {
|
||||
cd mocktail
|
||||
cd nightcap
|
||||
|
||||
sed -i \
|
||||
's|add_subdirectory(third_party/Vulkan-Headers EXCLUDE_FROM_ALL)|find_package(VulkanHeaders CONFIG REQUIRED)|' \
|
||||
@@ -59,7 +61,7 @@ prepare() {
|
||||
}
|
||||
|
||||
build() {
|
||||
cmake -S mocktail -B build -G Ninja \
|
||||
cmake -S nightcap -B build -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
@@ -72,6 +74,6 @@ build() {
|
||||
|
||||
package() {
|
||||
DESTDIR="${pkgdir}" cmake --install build
|
||||
install -Dm644 mocktail/LICENSE \
|
||||
install -Dm644 nightcap/LICENSE \
|
||||
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||
}
|
||||
@@ -0,0 +1,602 @@
|
||||
// cc -O2 -o mocktail_webview_host mocktail_webview_host.c $(pkg-config --cflags --libs gtk4 webkitgtk-6.0)
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <glib-unix.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <webkit/webkit.h>
|
||||
|
||||
#define PORT 2137
|
||||
#define MAX_PACKET (64u * 1024u + 12u)
|
||||
#define VERSION "2.725.1142"
|
||||
|
||||
enum {
|
||||
OP_LOAD_URL = 1, OP_SET_TITLE = 2, OP_SET_VISIBLE = 3, OP_EVAL_JS = 4,
|
||||
OP_CLOSE = 5, OP_SET_BACK_DISABLED = 6, OP_SHOW_DOMAIN_TITLE = 7,
|
||||
OP_SET_COOKIE = 8, OP_CLEAR_COOKIE = 9, OP_RETAIN_COOKIE = 10
|
||||
};
|
||||
|
||||
enum { EV_EXECUTE_ROBLOX = 1, EV_ROBLOX_WK_HYBRID = 2, EV_READY = 3, EV_COOKIE = 4 };
|
||||
|
||||
static const char kBridge[] =
|
||||
"(() => { 'use strict';"
|
||||
" const h = window.webkit && window.webkit.messageHandlers;"
|
||||
" const handler = h && h.executeRoblox; if (!handler) return;"
|
||||
" const bridge = {};"
|
||||
" Object.defineProperty(bridge, 'executeRoblox', {"
|
||||
" value: (q) => handler.postMessage(JSON.parse(q)),"
|
||||
" enumerable: true, writable: false, configurable: false });"
|
||||
" try { Object.defineProperty(window, '__globalRobloxAndroidBridge__', {"
|
||||
" value: bridge, enumerable: true, writable: false, configurable: false });"
|
||||
" } catch (_) {} })();";
|
||||
|
||||
static GtkApplication *app;
|
||||
static GtkWindow *window;
|
||||
static WebKitWebView *view;
|
||||
static WebKitNetworkSession *session;
|
||||
static int listener = -1;
|
||||
static int client = -1;
|
||||
static guint client_read_source;
|
||||
static guint client_write_source;
|
||||
static GByteArray *rx;
|
||||
static GQueue *tx;
|
||||
static size_t tx_offset;
|
||||
static gboolean domain_title;
|
||||
static gboolean login_page;
|
||||
static gboolean back_disabled;
|
||||
static gboolean shutting_down;
|
||||
static char *last_cookie;
|
||||
|
||||
static gboolean flush_tx(gint fd, GIOCondition cond, gpointer data);
|
||||
static gboolean on_client(gint fd, GIOCondition cond, gpointer data);
|
||||
static void apply(uint8_t op, const char *payload, size_t size);
|
||||
static void create_surface(void);
|
||||
static void destroy_surface(void);
|
||||
|
||||
static void drop_client(const char *why) {
|
||||
if (client < 0) return;
|
||||
fprintf(stderr, "client dropped: %s\n", why);
|
||||
if (client_read_source) {
|
||||
g_source_remove(client_read_source);
|
||||
client_read_source = 0;
|
||||
}
|
||||
if (client_write_source) {
|
||||
g_source_remove(client_write_source);
|
||||
client_write_source = 0;
|
||||
}
|
||||
close(client);
|
||||
client = -1;
|
||||
g_byte_array_set_size(rx, 0);
|
||||
while (!g_queue_is_empty(tx)) g_bytes_unref(g_queue_pop_head(tx));
|
||||
tx_offset = 0;
|
||||
g_free(last_cookie);
|
||||
last_cookie = NULL;
|
||||
destroy_surface();
|
||||
}
|
||||
|
||||
static void quit_app(void) {
|
||||
if (shutting_down) return;
|
||||
shutting_down = TRUE;
|
||||
drop_client("shutting down");
|
||||
if (app) g_application_quit(G_APPLICATION(app));
|
||||
}
|
||||
|
||||
static void send_event(uint8_t type, const char *payload, size_t size) {
|
||||
if (client < 0) return;
|
||||
size_t body = 12 + size;
|
||||
uint8_t *buffer = g_malloc0(4 + body);
|
||||
buffer[0] = body >> 24; buffer[1] = body >> 16; buffer[2] = body >> 8; buffer[3] = body;
|
||||
memcpy(buffer + 4, "MWVE", 4);
|
||||
buffer[8] = 1;
|
||||
buffer[9] = type;
|
||||
buffer[12] = size >> 24; buffer[13] = size >> 16; buffer[14] = size >> 8; buffer[15] = size;
|
||||
if (size) memcpy(buffer + 16, payload, size);
|
||||
g_queue_push_tail(tx, g_bytes_new_take(buffer, 4 + body));
|
||||
if (!client_write_source)
|
||||
client_write_source = g_unix_fd_add(client, G_IO_OUT | G_IO_HUP | G_IO_ERR, flush_tx, NULL);
|
||||
}
|
||||
|
||||
static gboolean flush_tx(gint fd, GIOCondition cond, gpointer data) {
|
||||
(void)data;
|
||||
if (cond & (G_IO_HUP | G_IO_ERR)) {
|
||||
client_write_source = 0;
|
||||
drop_client("write side closed");
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
while (!g_queue_is_empty(tx)) {
|
||||
GBytes *head = g_queue_peek_head(tx);
|
||||
gsize length;
|
||||
const uint8_t *bytes = g_bytes_get_data(head, &length);
|
||||
ssize_t count = send(fd, bytes + tx_offset, length - tx_offset, MSG_DONTWAIT | MSG_NOSIGNAL);
|
||||
if (count < 0 && errno == EINTR) continue;
|
||||
if (count < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) return G_SOURCE_CONTINUE;
|
||||
if (count <= 0) {
|
||||
client_write_source = 0;
|
||||
drop_client("write failed");
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
tx_offset += (size_t)count;
|
||||
if (tx_offset == length) {
|
||||
tx_offset = 0;
|
||||
g_bytes_unref(g_queue_pop_head(tx));
|
||||
}
|
||||
}
|
||||
client_write_source = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static char *user_agent(void) {
|
||||
const char *v = getenv("MOCKTAIL_ROBLOX_VERSION");
|
||||
if (!v || !*v) v = VERSION;
|
||||
return g_strdup_printf(
|
||||
"Mozilla/5.0 AppleWebKit/605.1.15 (KHTML, like Gecko) ROBLOX Android App "
|
||||
"%s Tablet Hybrid() GooglePlayStore RobloxApp/%s (GlobalDist; GooglePlayStore)", v, v);
|
||||
}
|
||||
|
||||
static void on_cookies(GObject *source, GAsyncResult *result, gpointer data) {
|
||||
(void)data;
|
||||
GError *error = NULL;
|
||||
GList *cookies = webkit_cookie_manager_get_cookies_finish(WEBKIT_COOKIE_MANAGER(source), result, &error);
|
||||
for (GList *i = cookies; i; i = i->next) {
|
||||
SoupCookie *c = i->data;
|
||||
const char *name = soup_cookie_get_name(c);
|
||||
const char *value = soup_cookie_get_value(c);
|
||||
if (name && value && strcmp(name, ".ROBLOSECURITY") == 0 && *value &&
|
||||
(!last_cookie || strcmp(last_cookie, value) != 0)) {
|
||||
g_free(last_cookie);
|
||||
last_cookie = g_strdup(value);
|
||||
send_event(EV_COOKIE, value, strlen(value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_list_free_full(cookies, (GDestroyNotify)soup_cookie_free);
|
||||
g_clear_error(&error);
|
||||
}
|
||||
|
||||
static void request_cookie(void) {
|
||||
if (!login_page || !session || client < 0) return;
|
||||
webkit_cookie_manager_get_cookies(webkit_network_session_get_cookie_manager(session),
|
||||
"https://www.roblox.com/", NULL, on_cookies, NULL);
|
||||
}
|
||||
|
||||
static void on_cookie_changed(WebKitCookieManager *manager, gpointer data) {
|
||||
(void)manager; (void)data;
|
||||
request_cookie();
|
||||
}
|
||||
|
||||
static void configure_agent(const char *url) {
|
||||
WebKitSettings *settings = webkit_web_view_get_settings(view);
|
||||
GUri *uri = g_uri_parse(url, G_URI_FLAGS_NONE, NULL);
|
||||
const char *path = uri ? g_uri_get_path(uri) : NULL;
|
||||
login_page = path && (strcmp(path, "/login") == 0 || strcmp(path, "/login/") == 0);
|
||||
if (uri) g_uri_unref(uri);
|
||||
if (login_page) {
|
||||
webkit_settings_set_user_agent(settings, NULL);
|
||||
request_cookie();
|
||||
} else {
|
||||
char *agent = user_agent();
|
||||
webkit_settings_set_user_agent(settings, agent);
|
||||
g_free(agent);
|
||||
}
|
||||
}
|
||||
|
||||
static void update_title(void) {
|
||||
if (!domain_title || !window || !view) return;
|
||||
const char *uri = webkit_web_view_get_uri(view);
|
||||
if (!uri) return;
|
||||
GUri *parsed = g_uri_parse(uri, G_URI_FLAGS_NONE, NULL);
|
||||
if (!parsed) return;
|
||||
const char *host = g_uri_get_host(parsed);
|
||||
if (host) gtk_window_set_title(window, host);
|
||||
g_uri_unref(parsed);
|
||||
}
|
||||
|
||||
static void on_load_changed(WebKitWebView *v, WebKitLoadEvent event, gpointer data) {
|
||||
(void)v; (void)data;
|
||||
if (event == WEBKIT_LOAD_COMMITTED || event == WEBKIT_LOAD_FINISHED) {
|
||||
update_title();
|
||||
request_cookie();
|
||||
}
|
||||
}
|
||||
|
||||
static GtkWidget *on_create(WebKitWebView *v, WebKitNavigationAction *action, gpointer data) {
|
||||
(void)v; (void)data;
|
||||
WebKitURIRequest *request = webkit_navigation_action_get_request(action);
|
||||
const char *uri = request ? webkit_uri_request_get_uri(request) : NULL;
|
||||
if (uri && view) webkit_web_view_load_uri(view, uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *json_string_after(const char *json, const char *key) {
|
||||
char *needle = g_strdup_printf("\"%s\"", key);
|
||||
const char *at = strstr(json, needle);
|
||||
g_free(needle);
|
||||
if (!at) return NULL;
|
||||
at = strchr(at + strlen(key) + 2, ':');
|
||||
if (!at) return NULL;
|
||||
at++;
|
||||
while (*at == ' ') at++;
|
||||
if (*at != '"') return NULL;
|
||||
at++;
|
||||
GString *out = g_string_new(NULL);
|
||||
while (*at && *at != '"') {
|
||||
if (*at == '\\' && at[1]) at++;
|
||||
g_string_append_c(out, *at);
|
||||
at++;
|
||||
}
|
||||
return g_string_free(out, FALSE);
|
||||
}
|
||||
|
||||
static void on_callback_done(GObject *source, GAsyncResult *result, gpointer data) {
|
||||
gboolean close_after = GPOINTER_TO_INT(data);
|
||||
GError *error = NULL;
|
||||
JSCValue *value = webkit_web_view_evaluate_javascript_finish(WEBKIT_WEB_VIEW(source), result, &error);
|
||||
gboolean confirmed = !error && value && jsc_value_is_boolean(value) && jsc_value_to_boolean(value);
|
||||
if (value) g_object_unref(value);
|
||||
g_clear_error(&error);
|
||||
if (confirmed && close_after) destroy_surface();
|
||||
}
|
||||
|
||||
static void acknowledge_page_command(const char *json) {
|
||||
if (!view || !json) return;
|
||||
char *feature = json_string_after(json, "feature");
|
||||
char *callback = json_string_after(json, "callbackID");
|
||||
if (feature && callback && *callback) {
|
||||
gboolean success = strcmp(feature, "CaptchaSuccess") == 0;
|
||||
if (success || strcmp(feature, "CaptchaShown") == 0) {
|
||||
GString *quoted = g_string_new("\"");
|
||||
for (const char *p = callback; *p; p++) {
|
||||
if (*p == '"' || *p == '\\') g_string_append_c(quoted, '\\');
|
||||
g_string_append_c(quoted, *p);
|
||||
}
|
||||
g_string_append_c(quoted, '"');
|
||||
char *script = g_strdup_printf(
|
||||
"(() => { try { if (window.Roblox && window.Roblox.Hybrid && "
|
||||
"window.Roblox.Hybrid.Bridge && typeof window.Roblox.Hybrid.Bridge.nativeCallback === 'function') { "
|
||||
"window.Roblox.Hybrid.Bridge.nativeCallback(%s, true, {}); return true; } } catch (_) {} return false; })();",
|
||||
quoted->str);
|
||||
webkit_web_view_evaluate_javascript(view, script, -1, NULL, NULL, NULL,
|
||||
on_callback_done, GINT_TO_POINTER(success));
|
||||
g_free(script);
|
||||
g_string_free(quoted, TRUE);
|
||||
}
|
||||
}
|
||||
g_free(feature);
|
||||
g_free(callback);
|
||||
}
|
||||
|
||||
static void forward(uint8_t type, JSCValue *value) {
|
||||
char *text = NULL;
|
||||
if (jsc_value_is_string(value)) text = jsc_value_to_string(value);
|
||||
else if (jsc_value_is_object(value)) text = jsc_value_to_json(value, 0);
|
||||
if (!text) return;
|
||||
size_t size = strlen(text);
|
||||
if (size && size <= 64u * 1024u) {
|
||||
send_event(type, text, size);
|
||||
acknowledge_page_command(text);
|
||||
}
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
static void on_execute_roblox(WebKitUserContentManager *m, JSCValue *value, gpointer data) {
|
||||
(void)m; (void)data;
|
||||
forward(EV_EXECUTE_ROBLOX, value);
|
||||
}
|
||||
|
||||
static void on_hybrid(WebKitUserContentManager *m, JSCValue *value, gpointer data) {
|
||||
(void)m; (void)data;
|
||||
if (!jsc_value_is_object(value)) return;
|
||||
JSCValue *command = jsc_value_object_get_property(value, "command");
|
||||
if (command) {
|
||||
forward(EV_ROBLOX_WK_HYBRID, command);
|
||||
g_object_unref(command);
|
||||
}
|
||||
}
|
||||
|
||||
static void on_view_close(WebKitWebView *v, gpointer data) {
|
||||
(void)v; (void)data;
|
||||
destroy_surface();
|
||||
}
|
||||
|
||||
static gboolean on_close_request(GtkWindow *w, gpointer data) {
|
||||
(void)w; (void)data;
|
||||
window = NULL;
|
||||
view = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void on_reload(GtkButton *button, gpointer data) {
|
||||
(void)button; (void)data;
|
||||
if (view) webkit_web_view_reload_bypass_cache(view);
|
||||
}
|
||||
|
||||
static void on_eval(GObject *source, GAsyncResult *result, gpointer data) {
|
||||
(void)data;
|
||||
GError *error = NULL;
|
||||
JSCValue *value = webkit_web_view_evaluate_javascript_finish(WEBKIT_WEB_VIEW(source), result, &error);
|
||||
if (value) g_object_unref(value);
|
||||
g_clear_error(&error);
|
||||
}
|
||||
|
||||
static void on_cookie_done(GObject *source, GAsyncResult *result, gpointer data) {
|
||||
(void)data;
|
||||
GError *error = NULL;
|
||||
webkit_cookie_manager_add_cookie_finish(WEBKIT_COOKIE_MANAGER(source), result, &error);
|
||||
g_clear_error(&error);
|
||||
}
|
||||
|
||||
static void on_cookie_deleted(GObject *source, GAsyncResult *result, gpointer data) {
|
||||
(void)data;
|
||||
GError *error = NULL;
|
||||
webkit_cookie_manager_delete_cookie_finish(WEBKIT_COOKIE_MANAGER(source), result, &error);
|
||||
g_clear_error(&error);
|
||||
}
|
||||
|
||||
static void ensure_session(void) {
|
||||
if (session) return;
|
||||
gchar *data_dir = g_build_filename(g_get_user_data_dir(), "mocktail", "webview", NULL);
|
||||
gchar *cache_dir = g_build_filename(g_get_user_cache_dir(), "mocktail", "webview", NULL);
|
||||
g_mkdir_with_parents(data_dir, 0700);
|
||||
g_mkdir_with_parents(cache_dir, 0700);
|
||||
gchar *cookie_db = g_build_filename(data_dir, "cookies.sqlite", NULL);
|
||||
session = webkit_network_session_new(data_dir, cache_dir);
|
||||
g_free(data_dir);
|
||||
g_free(cache_dir);
|
||||
WebKitCookieManager *cookies = webkit_network_session_get_cookie_manager(session);
|
||||
webkit_cookie_manager_set_persistent_storage(cookies, cookie_db, WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
|
||||
webkit_cookie_manager_set_accept_policy(cookies, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
|
||||
g_signal_connect(cookies, "changed", G_CALLBACK(on_cookie_changed), NULL);
|
||||
g_free(cookie_db);
|
||||
webkit_network_session_set_itp_enabled(session, FALSE);
|
||||
webkit_network_session_set_persistent_credential_storage_enabled(session, TRUE);
|
||||
}
|
||||
|
||||
static void create_surface(void) {
|
||||
if (window || view) return;
|
||||
ensure_session();
|
||||
|
||||
WebKitUserContentManager *manager = webkit_user_content_manager_new();
|
||||
WebKitWebView *created = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, "network-session", session,
|
||||
"user-content-manager", manager, NULL));
|
||||
g_object_unref(manager);
|
||||
manager = webkit_web_view_get_user_content_manager(created);
|
||||
g_signal_connect(manager, "script-message-received::executeRoblox", G_CALLBACK(on_execute_roblox), NULL);
|
||||
g_signal_connect(manager, "script-message-received::RobloxWKHybrid", G_CALLBACK(on_hybrid), NULL);
|
||||
g_signal_connect(manager, "script-message-received::mocktailRobloxBridge", G_CALLBACK(on_execute_roblox), NULL);
|
||||
webkit_user_content_manager_register_script_message_handler(manager, "executeRoblox", NULL);
|
||||
webkit_user_content_manager_register_script_message_handler(manager, "RobloxWKHybrid", NULL);
|
||||
webkit_user_content_manager_register_script_message_handler(manager, "mocktailRobloxBridge", NULL);
|
||||
WebKitUserScript *script = webkit_user_script_new(kBridge, WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
|
||||
WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START, NULL, NULL);
|
||||
webkit_user_content_manager_add_script(manager, script);
|
||||
webkit_user_script_unref(script);
|
||||
|
||||
WebKitSettings *settings = webkit_web_view_get_settings(created);
|
||||
webkit_settings_set_enable_javascript(settings, TRUE);
|
||||
webkit_settings_set_javascript_can_open_windows_automatically(settings, TRUE);
|
||||
webkit_settings_set_enable_back_forward_navigation_gestures(settings, !back_disabled);
|
||||
char *agent = user_agent();
|
||||
webkit_settings_set_user_agent(settings, agent);
|
||||
g_free(agent);
|
||||
|
||||
g_signal_connect(created, "load-changed", G_CALLBACK(on_load_changed), NULL);
|
||||
g_signal_connect(created, "create", G_CALLBACK(on_create), NULL);
|
||||
g_signal_connect(created, "close", G_CALLBACK(on_view_close), NULL);
|
||||
|
||||
GtkWindow *created_window = GTK_WINDOW(gtk_application_window_new(app));
|
||||
gtk_window_set_title(created_window, "Roblox");
|
||||
gtk_window_set_default_size(created_window, 1100, 760);
|
||||
GtkWidget *header = gtk_header_bar_new();
|
||||
GtkWidget *reload = gtk_button_new_from_icon_name("view-refresh-symbolic");
|
||||
g_signal_connect(reload, "clicked", G_CALLBACK(on_reload), NULL);
|
||||
gtk_header_bar_pack_start(GTK_HEADER_BAR(header), reload);
|
||||
gtk_window_set_titlebar(created_window, header);
|
||||
gtk_widget_set_vexpand(GTK_WIDGET(created), TRUE);
|
||||
gtk_window_set_child(created_window, GTK_WIDGET(created));
|
||||
g_signal_connect(created_window, "close-request", G_CALLBACK(on_close_request), NULL);
|
||||
|
||||
view = created;
|
||||
window = created_window;
|
||||
}
|
||||
|
||||
static void destroy_surface(void) {
|
||||
GtkWindow *w = window;
|
||||
window = NULL;
|
||||
view = NULL;
|
||||
login_page = FALSE;
|
||||
domain_title = FALSE;
|
||||
if (w) gtk_window_destroy(w);
|
||||
}
|
||||
|
||||
static void apply(uint8_t op, const char *payload, size_t size) {
|
||||
if (op == OP_CLOSE) {
|
||||
destroy_surface();
|
||||
return;
|
||||
}
|
||||
if (op == OP_SET_BACK_DISABLED) {
|
||||
back_disabled = size == 1 && payload[0];
|
||||
if (view) webkit_settings_set_enable_back_forward_navigation_gestures(
|
||||
webkit_web_view_get_settings(view), !back_disabled);
|
||||
return;
|
||||
}
|
||||
if (op == OP_SHOW_DOMAIN_TITLE) {
|
||||
domain_title = size == 1 && payload[0];
|
||||
update_title();
|
||||
return;
|
||||
}
|
||||
if (op == OP_SET_COOKIE || op == OP_CLEAR_COOKIE) {
|
||||
ensure_session();
|
||||
WebKitCookieManager *cookies = webkit_network_session_get_cookie_manager(session);
|
||||
if (op == OP_SET_COOKIE) {
|
||||
char *value = g_strndup(payload, size);
|
||||
SoupCookie *cookie = soup_cookie_new(".ROBLOSECURITY", value, ".roblox.com", "/", -1);
|
||||
g_free(value);
|
||||
if (cookie) {
|
||||
soup_cookie_set_secure(cookie, TRUE);
|
||||
soup_cookie_set_http_only(cookie, TRUE);
|
||||
soup_cookie_set_same_site_policy(cookie, SOUP_SAME_SITE_POLICY_LAX);
|
||||
webkit_cookie_manager_add_cookie(cookies, cookie, NULL, on_cookie_done, NULL);
|
||||
soup_cookie_free(cookie);
|
||||
}
|
||||
} else {
|
||||
SoupCookie *cookie = soup_cookie_new(".ROBLOSECURITY", "", ".roblox.com", "/", -1);
|
||||
if (cookie) {
|
||||
webkit_cookie_manager_delete_cookie(cookies, cookie, NULL, on_cookie_deleted, NULL);
|
||||
soup_cookie_free(cookie);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (op == OP_RETAIN_COOKIE) return;
|
||||
if (op == OP_LOAD_URL) create_surface();
|
||||
if (!window || !view) return;
|
||||
switch (op) {
|
||||
case OP_LOAD_URL: {
|
||||
char *url = g_strndup(payload, size);
|
||||
configure_agent(url);
|
||||
webkit_web_view_load_uri(view, url);
|
||||
gtk_window_present(window);
|
||||
g_free(url);
|
||||
break;
|
||||
}
|
||||
case OP_SET_TITLE: {
|
||||
char *title = g_strndup(payload, size);
|
||||
gtk_window_set_title(window, title);
|
||||
g_free(title);
|
||||
break;
|
||||
}
|
||||
case OP_SET_VISIBLE:
|
||||
if (size == 1 && payload[0]) gtk_window_present(window);
|
||||
else gtk_widget_set_visible(GTK_WIDGET(window), FALSE);
|
||||
break;
|
||||
case OP_EVAL_JS:
|
||||
webkit_web_view_evaluate_javascript(view, payload, (gssize)size, NULL, NULL, NULL, on_eval, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean process_frames(void) {
|
||||
while (rx->len >= 4) {
|
||||
uint32_t length = ((uint32_t)rx->data[0] << 24) | ((uint32_t)rx->data[1] << 16) |
|
||||
((uint32_t)rx->data[2] << 8) | rx->data[3];
|
||||
if (length > MAX_PACKET) return FALSE;
|
||||
if (rx->len < 4u + length) break;
|
||||
uint8_t *copy = g_memdup2(rx->data + 4, length);
|
||||
g_byte_array_remove_range(rx, 0, 4 + length);
|
||||
if (length >= 12 && memcmp(copy, "MWVC", 4) == 0) {
|
||||
size_t size = ((size_t)copy[8] << 24) | ((size_t)copy[9] << 16) |
|
||||
((size_t)copy[10] << 8) | copy[11];
|
||||
if (size == length - 12) apply(copy[5], (const char *)copy + 12, size);
|
||||
}
|
||||
g_free(copy);
|
||||
if (client < 0) return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_client(gint fd, GIOCondition cond, gpointer data) {
|
||||
(void)data;
|
||||
uint8_t buffer[8192];
|
||||
while (TRUE) {
|
||||
ssize_t count = read(fd, buffer, sizeof buffer);
|
||||
if (count < 0 && errno == EINTR) continue;
|
||||
if (count < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) break;
|
||||
if (count <= 0) {
|
||||
client_read_source = 0;
|
||||
drop_client("client closed");
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
g_byte_array_append(rx, buffer, (guint)count);
|
||||
if (!process_frames()) {
|
||||
client_read_source = 0;
|
||||
drop_client("bad frame");
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
if (client < 0) return G_SOURCE_REMOVE;
|
||||
}
|
||||
if (cond & (G_IO_HUP | G_IO_ERR)) {
|
||||
client_read_source = 0;
|
||||
drop_client("client hung up");
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static gboolean on_listener(gint fd, GIOCondition cond, gpointer data) {
|
||||
(void)cond; (void)data;
|
||||
int accepted = accept(fd, NULL, NULL);
|
||||
if (accepted < 0) return G_SOURCE_CONTINUE;
|
||||
if (client >= 0) drop_client("replaced by a new connection");
|
||||
fcntl(accepted, F_SETFD, FD_CLOEXEC);
|
||||
fcntl(accepted, F_SETFL, fcntl(accepted, F_GETFL) | O_NONBLOCK);
|
||||
int one = 1;
|
||||
setsockopt(accepted, IPPROTO_TCP, TCP_NODELAY, &one, sizeof one);
|
||||
client = accepted;
|
||||
fprintf(stderr, "client connected\n");
|
||||
client_read_source = g_unix_fd_add(client, G_IO_IN | G_IO_HUP | G_IO_ERR, on_client, NULL);
|
||||
send_event(EV_READY, "", 0);
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static int listen_socket(void) {
|
||||
int fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) return -1;
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
int one = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one);
|
||||
struct sockaddr_in address;
|
||||
memset(&address, 0, sizeof address);
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_port = htons(PORT);
|
||||
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
if (bind(fd, (struct sockaddr *)&address, sizeof address) != 0 || listen(fd, 4) != 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void activate(GtkApplication *application, gpointer data) {
|
||||
(void)application; (void)data;
|
||||
}
|
||||
|
||||
static gboolean on_sigterm(gpointer data) {
|
||||
(void)data;
|
||||
quit_app();
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
(void)argc;
|
||||
setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "1", 0);
|
||||
setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "1", 0);
|
||||
rx = g_byte_array_new();
|
||||
tx = g_queue_new();
|
||||
listener = listen_socket();
|
||||
if (listener < 0) {
|
||||
fprintf(stderr, "cannot listen on 127.0.0.1:%d: %s\n", PORT, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
g_unix_fd_add(listener, G_IO_IN, on_listener, NULL);
|
||||
g_unix_signal_add(SIGTERM, on_sigterm, NULL);
|
||||
g_unix_signal_add(SIGINT, on_sigterm, NULL);
|
||||
app = gtk_application_new("org.mocktail.WebViewHost", G_APPLICATION_NON_UNIQUE);
|
||||
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
|
||||
g_application_hold(G_APPLICATION(app));
|
||||
int status = g_application_run(G_APPLICATION(app), 1, argv);
|
||||
g_object_unref(app);
|
||||
return status;
|
||||
}
|
||||
@@ -21,22 +21,19 @@
|
||||
Sign in to Roblox, browse experiences, and play them on Linux.
|
||||
</p>
|
||||
<p>
|
||||
Mocktail is an independent community project. It is not affiliated with
|
||||
Roblox Corporation or VinegarHQ, and the Roblox client is not included.
|
||||
Nightcap is an independent community project, forked from Mocktail. It
|
||||
is not affiliated with Roblox Corporation or VinegarHQ, and the Roblox
|
||||
client is not included.
|
||||
</p>
|
||||
</description>
|
||||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<image>https://raw.githubusercontent.com/komaruworld/mocktail/88b7382577aa138a2d16619b091f69abcdf7da15/assets/screenshots/flatpak-home.png</image>
|
||||
<image>https://raw.githubusercontent.com/CoderDayton/nightcap/main/assets/screenshots/flatpak-home.png</image>
|
||||
<caption>Browse Roblox experiences</caption>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<image>https://raw.githubusercontent.com/komaruworld/mocktail/88b7382577aa138a2d16619b091f69abcdf7da15/assets/screenshots/flatpak-gameplay-tower.png</image>
|
||||
<caption>Play Tower of Hell on Linux</caption>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<image>https://raw.githubusercontent.com/komaruworld/mocktail/88b7382577aa138a2d16619b091f69abcdf7da15/assets/screenshots/flatpak-gameplay-lobby.png</image>
|
||||
<caption>Play DOORS on Linux</caption>
|
||||
<image>https://raw.githubusercontent.com/CoderDayton/nightcap/main/assets/screenshots/flatpak-gameplay-tower.png</image>
|
||||
<caption>Play Murder Mystery 2 on Linux</caption>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
<launchable type="desktop-id">io.github.CoderDayton.nightcap.desktop</launchable>
|
||||
@@ -56,45 +53,87 @@
|
||||
<binary>mocktail</binary>
|
||||
</provides>
|
||||
<releases>
|
||||
<release version="1.0.4" date="2026-09-11">
|
||||
<release version="0.3.4" date="2026-10-11">
|
||||
<description>
|
||||
<ul>
|
||||
<li>Fixed login issues</li>
|
||||
<li>Fixed low-resolution textures, skybox rendering and HiDPI scaling.</li>
|
||||
<li>Added vc support.</li>
|
||||
<li>Added Xbox and PlayStation gamepad support.</li>
|
||||
<li>Added Nix support</li>
|
||||
<li>Improved text input, fullscreen mode, window sizing, and mouse controls.</li>
|
||||
<li>Updated support for Roblox 2.736.1408.</li>
|
||||
<li>Fixed Roblox 2.742 being rejected as an update.</li>
|
||||
<li>The new Roblox home screen and its side menu now show.</li>
|
||||
<li>Fixed the voice chat microphone after Roblox updates.</li>
|
||||
<li>Anti-aliasing is no longer forced off.</li>
|
||||
<li>Nightcap now uses Wayland on NVIDIA Wayland sessions.</li>
|
||||
<li>Fixed a missing picture on machines whose graphics card runs a different driver.</li>
|
||||
<li>Fewer frame hitches while textures load.</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="1.0.3" date="2026-08-16">
|
||||
<release version="0.3.3" date="2026-10-04">
|
||||
<description>
|
||||
<ul>
|
||||
<li>Fixed issues with downloading Roblox on first launch</li>
|
||||
<li>Added fflags.json for custom FFlags</li>
|
||||
<li>Added a message if your cookies have expired</li>
|
||||
<li>Joining a friend from a follow user link now works.</li>
|
||||
<li>Roblox textures decode about 3 times faster, so loading stalls are shorter.</li>
|
||||
<li>A failed Roblox update now restores your previous install instead of leaving it half changed.</li>
|
||||
<li>Fixed crashes and freezes with audio, the text overlay, the mouse lock and saved themes.</li>
|
||||
<li>Going to another page in the web view no longer closes it.</li>
|
||||
<li>Clicking while typing no longer closes the text box.</li>
|
||||
<li>Fixed the sky showing the wrong textures.</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="1.0.2" date="2026-08-14">
|
||||
<release version="0.3.2" date="2026-09-29">
|
||||
<description>
|
||||
<ul>
|
||||
<li>Fixed the “Roblox is out of date” bug</li>
|
||||
<li>Improved logging</li>
|
||||
<li>Fixed issues with Discord RPC where the game you were playing wasn’t displayed</li>
|
||||
<li>Added experimental support for ARM64 Linux.</li>
|
||||
<li>Fixed login stalling after passing a verification check.</li>
|
||||
<li>Fixed login check windows staying open after they were solved.</li>
|
||||
<li>Fixed Play on a private server doing nothing until a sidebar tab was clicked.</li>
|
||||
<li>Less stutter while joining a game and while textures load in.</li>
|
||||
<li>Middle click and natural scrolling now work as expected.</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="1.0.1" date="2026-08-13">
|
||||
<release version="0.3.1" date="2026-09-20">
|
||||
<description>
|
||||
<ul>
|
||||
<li>Fix issues with GameMode</li>
|
||||
<li>Add Discord RPC support</li>
|
||||
<li>Added DEB, RPM, and pacman packages to every release.</li>
|
||||
<li>Smoother frames: textures no longer decode on the thread that submits the frame.</li>
|
||||
<li>Fixed the mouse pointer jumping when a right-click camera drag ended.</li>
|
||||
<li>Fixed the text caret not moving when a trailing space was typed.</li>
|
||||
<li>Faster typing in text boxes.</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.3.0" date="2026-09-18">
|
||||
<description>
|
||||
<ul>
|
||||
<li>Added a custom Discord presence: set the title, state, and icons.</li>
|
||||
<li>Added --profile to record a trace of the renderer's work.</li>
|
||||
<li>Faster texture loading: compressed textures decode and resample on worker threads.</li>
|
||||
<li>Lower CPU use while playing.</li>
|
||||
<li>Fixed GameMode pinning the game to a few CPU cores.</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.2.0" date="2026-09-16">
|
||||
<description>
|
||||
<ul>
|
||||
<li>Discord Rich Presence is on by default.</li>
|
||||
<li>Added input.raw_mouse for mouse look in the host's own units.</li>
|
||||
<li>Fixed mouse look after a long turn.</li>
|
||||
<li>Fixed a first-run failure with "cannot lock appStorage".</li>
|
||||
<li>Values in fflags.json now win over the performance preset.</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.1.0" date="2026-09-15">
|
||||
<description>
|
||||
<ul>
|
||||
<li>First Nightcap release, forked from Mocktail.</li>
|
||||
<li>Added ETC2 and EAC texture emulation on Vulkan.</li>
|
||||
<li>Added PNG texture overrides.</li>
|
||||
<li>Lower input latency.</li>
|
||||
<li>Roblox now sees the real host RAM and display size.</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.1.0" date="2026-08-12"/>
|
||||
</releases>
|
||||
</component>
|
||||
@@ -23,6 +23,7 @@
|
||||
elfutils,
|
||||
libglvnd,
|
||||
libplacebo,
|
||||
libpng,
|
||||
libsoup_3,
|
||||
libutf8proc,
|
||||
libyaml,
|
||||
@@ -92,6 +93,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
elfutils
|
||||
libglvnd
|
||||
libplacebo
|
||||
libpng
|
||||
libsoup_3
|
||||
libutf8proc
|
||||
libyaml
|
||||
|
||||
@@ -62,7 +62,7 @@ Branch=stable
|
||||
Url=${BASE_URL}/repo/
|
||||
RuntimeRepo=https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
Homepage=https://github.com/CoderDayton/nightcap
|
||||
Comment=Roblox on Linux, tuned for a real PC
|
||||
Comment=Roblox on Linux, tuned for desktop play
|
||||
Icon=${BASE_URL}/nightcap.svg
|
||||
GPGKey=${GPG_KEY}
|
||||
IsRuntime=false
|
||||
@@ -72,3 +72,20 @@ install -m 0644 -- "${PROJECT_DIR}/site/index.html" "${OUTPUT}/index.html"
|
||||
install -m 0644 -- "${PROJECT_DIR}/site/styles.css" "${OUTPUT}/styles.css"
|
||||
install -m 0644 -- "${PROJECT_DIR}/site/terms.html" "${OUTPUT}/terms.html"
|
||||
install -m 0644 -- "${PROJECT_DIR}/site/privacy.html" "${OUTPUT}/privacy.html"
|
||||
install -m 0644 -- "${PROJECT_DIR}/site/preview.png" "${OUTPUT}/preview.png"
|
||||
|
||||
cat >"${OUTPUT}/robots.txt" <<EOF
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: ${BASE_URL}/sitemap.xml
|
||||
EOF
|
||||
|
||||
cat >"${OUTPUT}/sitemap.xml" <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url><loc>${BASE_URL}/</loc></url>
|
||||
<url><loc>${BASE_URL}/terms.html</loc></url>
|
||||
<url><loc>${BASE_URL}/privacy.html</loc></url>
|
||||
</urlset>
|
||||
EOF
|
||||
@@ -461,6 +461,7 @@ LatestSupportedBootstrapProfile() {
|
||||
.version_code <= ($remote_version_code | tonumber)) and
|
||||
.status == "supported" and .default_allowed == true and
|
||||
.allow_legacy_binary_patches == false and
|
||||
(.abi // "x86_64") == "x86_64" and
|
||||
(.version_name | type) == "string" and
|
||||
(.version_name | length) > 0)] |
|
||||
group_by(.version_code) |
|
||||
@@ -495,6 +496,7 @@ SelectSupportedBootstrapFallback() {
|
||||
bootstrap_source="$(jq -er --argjson version_code "${fallback_version_code}" '
|
||||
[.sources[]? |
|
||||
select(.version_code == $version_code and
|
||||
(.abi // "x86_64") == "x86_64" and
|
||||
.provider == "uptodown")] |
|
||||
if length == 1 then .[0].provider else empty end
|
||||
' "${BOOTSTRAP_SOURCES_PATH}" 2>/dev/null || true)"
|
||||
|
||||
@@ -329,6 +329,7 @@ def run_trial(args, max_ctors, skipped_offsets, trial_id):
|
||||
log_path = args.log_dir / f"trial_{trial_id:03d}_max_{max_ctors}.log"
|
||||
env = os.environ.copy()
|
||||
env.update({
|
||||
"ROBLOX_LIB_PATH": str(args.libroblox),
|
||||
"MOCKTAIL_RUN_LIBROBLOX_CTORS": "1",
|
||||
"MOCKTAIL_LIBROBLOX_CTOR_POLICY": args.ctor_policy,
|
||||
"MOCKTAIL_GRAPHICS_BACKEND": args.graphics_backend,
|
||||
@@ -500,7 +501,7 @@ def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--project-root", type=Path, default=project_root)
|
||||
parser.add_argument("--run-script", type=Path,
|
||||
default=project_root / "scripts" / "run_sober.sh")
|
||||
default=project_root / "build" / "mocktail")
|
||||
parser.add_argument("--libroblox", type=Path,
|
||||
default=project_root / "rbx_bin" / "libroblox.so")
|
||||
parser.add_argument("--log-dir", type=Path,
|
||||
|
||||
@@ -10,18 +10,18 @@ readonly PROJECT_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd -P)"
|
||||
|
||||
BUILD_DIR="${PROJECT_ROOT}/build-flatpak"
|
||||
MANIFEST="${PROJECT_ROOT}/packaging/flatpak/io.github.CoderDayton.nightcap.json"
|
||||
JOBS="${MOCKTAIL_FLATPAK_JOBS:-4}"
|
||||
JOBS="${MOCKTAIL_FLATPAK_JOBS:-2}"
|
||||
|
||||
Usage() {
|
||||
cat <<'EOF'
|
||||
Usage: scripts/build_flatpak.sh [OPTIONS]
|
||||
|
||||
Build and install Mocktail as a per-user x86-64 Flatpak.
|
||||
Build and install Mocktail as a per-user Flatpak for the host architecture.
|
||||
|
||||
Options:
|
||||
--build-dir DIR Builder output directory (default: build-flatpak).
|
||||
--manifest FILE Flatpak manifest path.
|
||||
--jobs N Maximum parallel build jobs (default: 4).
|
||||
--jobs N Maximum parallel build jobs (default: 2).
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
@@ -93,8 +93,11 @@ done
|
||||
[[ "${JOBS}" =~ ^[1-9][0-9]*$ && "${JOBS}" -le 256 ]] ||
|
||||
Die "--jobs must be an integer between 1 and 256"
|
||||
|
||||
[[ "$(uname -m)" == x86_64 ]] ||
|
||||
Die "the Roblox payload and Flatpak manifest currently require x86-64"
|
||||
HOST_ARCH="$(uname -m)"
|
||||
case "${HOST_ARCH}" in
|
||||
x86_64|aarch64) ;;
|
||||
*) Die "Flatpak builds require an x86_64 or aarch64 Linux host" ;;
|
||||
esac
|
||||
command -v flatpak >/dev/null 2>&1 || Die "flatpak is required"
|
||||
|
||||
MANIFEST="$(realpath -e -- "${MANIFEST}")" ||
|
||||
@@ -123,7 +126,7 @@ CleanupStaleBuilderMounts
|
||||
|
||||
cd -- "${PROJECT_ROOT}"
|
||||
exec "${builder[@]}" \
|
||||
--arch=x86_64 \
|
||||
--arch="${HOST_ARCH}" \
|
||||
--jobs="${JOBS}" \
|
||||
--force-clean \
|
||||
--install-deps-from=flathub \
|
||||
|
||||
@@ -61,6 +61,7 @@ def supported_profiles(catalog: dict) -> list[dict]:
|
||||
if isinstance(profile, dict)
|
||||
and profile.get("status") == "supported"
|
||||
and profile.get("default_allowed") is True
|
||||
and profile.get("abi", ARCHITECTURE) == ARCHITECTURE
|
||||
and isinstance(profile.get("version_name"), str)
|
||||
and isinstance(profile.get("version_code"), int)
|
||||
]
|
||||
|
||||
@@ -23,6 +23,7 @@ supported.
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
from dataclasses import dataclass
|
||||
import hashlib
|
||||
import json
|
||||
@@ -161,6 +162,10 @@ class SignatureSpec:
|
||||
allow_registry_object_size_change: bool = False
|
||||
minimum_anchor_bytes: int = 6
|
||||
registry_size_indices: tuple[int, int] = (8, 12)
|
||||
# Instructions whose register operands the compiler may have chosen
|
||||
# differently. Each reference register must stand for one candidate
|
||||
# register across all of them, and the reverse.
|
||||
renamed_register_indices: tuple[int, ...] = ()
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -1075,6 +1080,51 @@ def semantic_shape(
|
||||
)
|
||||
|
||||
|
||||
def register_family(name: str) -> str:
|
||||
"""Return the 64-bit register that name is all or part of."""
|
||||
if len(name) >= 2 and name[0] == "r" and name[1].isdigit():
|
||||
return name.rstrip("bwd")
|
||||
for family in ("ax", "bx", "cx", "dx", "si", "di", "bp", "sp"):
|
||||
if name in (family, "e" + family, "r" + family):
|
||||
return "r" + family
|
||||
return name
|
||||
|
||||
|
||||
def renamed_shapes_match(
|
||||
reference_shape: tuple[Any, ...],
|
||||
candidate_shape: tuple[Any, ...],
|
||||
forward: dict[str, str],
|
||||
backward: dict[str, str],
|
||||
) -> bool:
|
||||
"""Compare two semantic shapes, letting register operands be renamed.
|
||||
|
||||
forward and backward hold the renames accepted so far and gain new ones.
|
||||
"""
|
||||
reference_mnemonic, reference_operands = reference_shape
|
||||
candidate_mnemonic, candidate_operands = candidate_shape
|
||||
if reference_mnemonic != candidate_mnemonic or len(reference_operands) != len(
|
||||
candidate_operands
|
||||
):
|
||||
return False
|
||||
for left, right in zip(reference_operands, candidate_operands):
|
||||
if left[0] != "reg" or right[0] != "reg":
|
||||
if left != right:
|
||||
return False
|
||||
continue
|
||||
if left[2] != right[2]:
|
||||
return False
|
||||
reference_family = register_family(left[1])
|
||||
candidate_family = register_family(right[1])
|
||||
if (
|
||||
forward.setdefault(reference_family, candidate_family)
|
||||
!= candidate_family
|
||||
or backward.setdefault(candidate_family, reference_family)
|
||||
!= reference_family
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def validate_semantic_match(
|
||||
reference: Sequence[Any],
|
||||
candidate: Sequence[Any],
|
||||
@@ -1082,6 +1132,8 @@ def validate_semantic_match(
|
||||
) -> None:
|
||||
if len(reference) != len(candidate):
|
||||
raise AnalyzerError("normalized signature instruction count changed")
|
||||
forward: dict[str, str] = {}
|
||||
backward: dict[str, str] = {}
|
||||
for index, (reference_instruction, candidate_instruction) in enumerate(
|
||||
zip(reference, candidate)
|
||||
):
|
||||
@@ -1089,8 +1141,14 @@ def validate_semantic_match(
|
||||
spec.allow_registry_object_size_change
|
||||
and index in spec.registry_size_indices
|
||||
)
|
||||
if semantic_shape(reference_instruction, wildcard_size) != semantic_shape(
|
||||
candidate_instruction, wildcard_size
|
||||
reference_shape = semantic_shape(reference_instruction, wildcard_size)
|
||||
candidate_shape = semantic_shape(candidate_instruction, wildcard_size)
|
||||
if (
|
||||
not renamed_shapes_match(
|
||||
reference_shape, candidate_shape, forward, backward
|
||||
)
|
||||
if index in spec.renamed_register_indices
|
||||
else reference_shape != candidate_shape
|
||||
):
|
||||
raise AnalyzerError(
|
||||
f"normalized instruction semantics changed at signature index {index}"
|
||||
@@ -1298,6 +1356,35 @@ def has_fmod_device_lists_select_contract(image: ElfImage, rva: int) -> bool:
|
||||
)
|
||||
|
||||
|
||||
FMOD_OUTPUT_FIELDS = frozenset({
|
||||
"vtable_rva",
|
||||
"string_constructor_rva",
|
||||
"count_method_rva",
|
||||
"info_method_rva",
|
||||
"current_method_rva",
|
||||
"select_method_rva",
|
||||
})
|
||||
FMOD_INPUT_FIELDS = (
|
||||
"input_count_method_rva",
|
||||
"input_info_method_rva",
|
||||
"input_current_method_rva",
|
||||
"input_select_method_rva",
|
||||
)
|
||||
|
||||
|
||||
def fmod_vtable_slots(layout: int, with_input: bool) -> dict[str, int]:
|
||||
"""Vtable slot of each FMOD method field in vtable layout 1 or 2."""
|
||||
slots = {
|
||||
"count_method_rva": 5,
|
||||
"info_method_rva": 6,
|
||||
"current_method_rva": 8 if layout == 2 else 7,
|
||||
"select_method_rva": 19 if layout == 2 else 17,
|
||||
}
|
||||
if with_input:
|
||||
slots.update(zip(FMOD_INPUT_FIELDS, (9, 10, 12, 18) if layout == 2 else (8, 9, 10, 16)))
|
||||
return slots
|
||||
|
||||
|
||||
def load_reference_runtime_profile(
|
||||
paths: Sequence[Path], reference_build_id: str
|
||||
) -> dict[str, Any]:
|
||||
@@ -1323,21 +1410,11 @@ def load_reference_runtime_profile(
|
||||
)
|
||||
if "fmod_output_device_bridge" in profile:
|
||||
bridge = profile["fmod_output_device_bridge"]
|
||||
fields = {
|
||||
"vtable_rva",
|
||||
"string_constructor_rva",
|
||||
"count_method_rva",
|
||||
"info_method_rva",
|
||||
"current_method_rva",
|
||||
"select_method_rva",
|
||||
}
|
||||
if (
|
||||
not isinstance(bridge, dict)
|
||||
or not fields <= set(bridge)
|
||||
or set(bridge) - fields - {"vtable_layout_version"} - {
|
||||
"input_count_method_rva", "input_info_method_rva",
|
||||
"input_current_method_rva", "input_select_method_rva",
|
||||
}
|
||||
or not FMOD_OUTPUT_FIELDS <= set(bridge)
|
||||
or set(bridge) - FMOD_OUTPUT_FIELDS - {"vtable_layout_version"}
|
||||
- set(FMOD_INPUT_FIELDS)
|
||||
or profile.get("allow_host_abi_bridges") is not True
|
||||
):
|
||||
raise AnalyzerError(
|
||||
@@ -1357,10 +1434,7 @@ def load_reference_runtime_profile(
|
||||
if field in result:
|
||||
previous = result[field]
|
||||
if field == "fmod_output_device_bridge":
|
||||
input_fields = {
|
||||
"input_count_method_rva", "input_info_method_rva",
|
||||
"input_current_method_rva", "input_select_method_rva",
|
||||
}
|
||||
input_fields = set(FMOD_INPUT_FIELDS)
|
||||
compatible = ((set(previous) ^ set(value)) <= input_fields and
|
||||
all(previous[key] == value[key]
|
||||
for key in previous.keys() & value.keys()))
|
||||
@@ -1382,12 +1456,7 @@ def derive_fmod_output_device_bridge(
|
||||
source: dict[str, int],
|
||||
) -> dict[str, Any]:
|
||||
source_layout = source.get("vtable_layout_version", 1)
|
||||
indexes = {
|
||||
"count_method_rva": 5,
|
||||
"info_method_rva": 6,
|
||||
"current_method_rva": 8 if source_layout == 2 else 7,
|
||||
"select_method_rva": 19 if source_layout == 2 else 17,
|
||||
}
|
||||
indexes = fmod_vtable_slots(source_layout, False)
|
||||
source_vtable = source["vtable_rva"]
|
||||
reference.require_relro_rva(source_vtable, (max(indexes.values()) + 1) * 8)
|
||||
reference_relocations = relative_relocation_map(reference)
|
||||
@@ -1472,7 +1541,10 @@ def derive_fmod_output_device_bridge(
|
||||
continue
|
||||
vtable = offset - indexes["info_method_rva"] * 8
|
||||
count_method = relocations.get(vtable + indexes["count_method_rva"] * 8)
|
||||
for layout, current_index, select_index in ((1, 7, 17), (2, 8, 19)):
|
||||
for layout in (1, 2):
|
||||
layout_slots = fmod_vtable_slots(layout, False)
|
||||
current_index = layout_slots["current_method_rva"]
|
||||
select_index = layout_slots["select_method_rva"]
|
||||
current_method = relocations.get(vtable + current_index * 8)
|
||||
selected = relocations.get(vtable + select_index * 8)
|
||||
if (
|
||||
@@ -1510,18 +1582,13 @@ def derive_fmod_output_device_bridge(
|
||||
}
|
||||
if layout != 1:
|
||||
result["vtable_layout_version"] = layout
|
||||
input_fields = (
|
||||
"input_count_method_rva", "input_info_method_rva",
|
||||
"input_current_method_rva", "input_select_method_rva",
|
||||
)
|
||||
if any(field in source for field in input_fields):
|
||||
if not all(field in source for field in input_fields):
|
||||
if any(field in source for field in FMOD_INPUT_FIELDS):
|
||||
if not all(field in source for field in FMOD_INPUT_FIELDS):
|
||||
raise AnalyzerError("reference FMOD input profile is incomplete")
|
||||
source_slots = (9, 10, 12, 18) if source_layout == 2 else (8, 9, 10, 16)
|
||||
target_slots = (9, 10, 12, 18) if layout == 2 else (8, 9, 10, 16)
|
||||
for field, old_slot, new_slot, length in zip(
|
||||
input_fields, source_slots, target_slots, (4, 16, 12, 16)
|
||||
):
|
||||
source_slots = fmod_vtable_slots(source_layout, True)
|
||||
target_slots = fmod_vtable_slots(layout, True)
|
||||
for field, length in zip(FMOD_INPUT_FIELDS, (4, 16, 12, 16)):
|
||||
old_slot, new_slot = source_slots[field], target_slots[field]
|
||||
if reference_relocations.get(source_vtable + old_slot * 8) != source[field]:
|
||||
raise AnalyzerError("reference FMOD input slot changed")
|
||||
target = relocations.get(vtable + new_slot * 8)
|
||||
@@ -1541,6 +1608,7 @@ def derive_runtime_compatibility(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
manifests: Sequence[Path],
|
||||
fallback: ElfImage | None = None,
|
||||
) -> dict[str, Any]:
|
||||
source = load_reference_runtime_profile(manifests, reference.build_id)
|
||||
result: dict[str, Any] = {}
|
||||
@@ -1563,9 +1631,38 @@ def derive_runtime_compatibility(
|
||||
result["fmod_output_device_bridge"] = derive_fmod_output_device_bridge(
|
||||
reference, candidate, fmod
|
||||
)
|
||||
elif fallback is not None:
|
||||
bridge = derive_fallback_fmod_output_device_bridge(
|
||||
fallback, candidate, manifests
|
||||
)
|
||||
if bridge is not None:
|
||||
result["fmod_output_device_bridge"] = bridge
|
||||
return result
|
||||
|
||||
|
||||
def derive_fallback_fmod_output_device_bridge(
|
||||
fallback: ElfImage,
|
||||
candidate: ElfImage,
|
||||
manifests: Sequence[Path],
|
||||
) -> dict[str, Any] | None:
|
||||
"""Derive the optional FMOD bridge from another build in the manifests.
|
||||
|
||||
Any failure leaves the bridge out.
|
||||
"""
|
||||
if fallback.build_id == candidate.build_id:
|
||||
return None
|
||||
try:
|
||||
fallback.validate_toolchain()
|
||||
fmod = load_reference_runtime_profile(manifests, fallback.build_id).get(
|
||||
"fmod_output_device_bridge"
|
||||
)
|
||||
if fmod is None:
|
||||
return None
|
||||
return derive_fmod_output_device_bridge(fallback, candidate, fmod)
|
||||
except AnalyzerError:
|
||||
return None
|
||||
|
||||
|
||||
def find_registry_function_entry(
|
||||
candidate: ElfImage,
|
||||
body_rva: int,
|
||||
@@ -1613,6 +1710,73 @@ def find_registry_function_entry(
|
||||
return entries[0]
|
||||
|
||||
|
||||
def find_renamed_registry_body_match(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
reference_body: Sequence[Any],
|
||||
minimum_anchor_bytes: int,
|
||||
) -> SignatureMatch:
|
||||
"""Find the registry initializer body under other temporary registers.
|
||||
|
||||
The body allocates the registry, clears it, and starts filling it:
|
||||
|
||||
0 mov edi, SIZE 6 xor esi, esi
|
||||
1 call allocate 7 call memset
|
||||
2 mov rbx, rax 8 mov ONE, 0x3f800000
|
||||
3 xor ZERO, ZERO 9 mov dword ptr [rbx + 0x20], ONE
|
||||
4 mov edx, SIZE 10 lea FIELD, [rbx + 0x28]
|
||||
5 mov rdi, rax
|
||||
|
||||
ZERO, ONE and FIELD are the compiler's choice. Instructions 4 to 7 use
|
||||
registers the calling convention fixes, so they are searched for by bytes
|
||||
and every hit is then checked against all eleven instructions.
|
||||
"""
|
||||
clear_index = 4
|
||||
clear_matches = find_signature_matches(
|
||||
reference,
|
||||
candidate,
|
||||
SignatureSpec(
|
||||
"registry-initializer-clear",
|
||||
reference_body[clear_index].address,
|
||||
4,
|
||||
True,
|
||||
minimum_anchor_bytes,
|
||||
(0, 0),
|
||||
),
|
||||
allow_multiple_candidates=True,
|
||||
)
|
||||
body_spec = SignatureSpec(
|
||||
"registry-initializer-body",
|
||||
reference_body[0].address,
|
||||
len(reference_body),
|
||||
True,
|
||||
minimum_anchor_bytes,
|
||||
(0, 4),
|
||||
(3, 8, 9, 10),
|
||||
)
|
||||
# Instructions 0 to 3 keep their lengths as long as ZERO stays one of r8
|
||||
# to r15, so the body starts this far before the clear sequence.
|
||||
lead = reference_body[clear_index].address - reference_body[0].address
|
||||
found = []
|
||||
for clear in clear_matches:
|
||||
if clear.rva < lead:
|
||||
continue
|
||||
try:
|
||||
body = disassemble(candidate, clear.rva - lead, len(reference_body))
|
||||
if body[clear_index].address != clear.rva:
|
||||
continue
|
||||
validate_semantic_match(reference_body, body, body_spec)
|
||||
except AnalyzerError:
|
||||
continue
|
||||
found.append(SignatureMatch(clear.rva - lead, tuple(reference_body), body))
|
||||
if len(found) != 1:
|
||||
raise AnalyzerError(
|
||||
f"signature registry-initializer-body matched {len(found)} "
|
||||
"candidate locations with renamed registers"
|
||||
)
|
||||
return found[0]
|
||||
|
||||
|
||||
def find_registry_signature_match(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
@@ -1633,7 +1797,18 @@ def find_registry_signature_match(
|
||||
spec.minimum_anchor_bytes,
|
||||
(0, 4),
|
||||
)
|
||||
body_match = find_signature_match(reference, candidate, body_spec)
|
||||
try:
|
||||
body_match = find_signature_match(reference, candidate, body_spec)
|
||||
except AnalyzerError:
|
||||
body_match = find_renamed_registry_body_match(
|
||||
reference,
|
||||
candidate,
|
||||
reference_full[
|
||||
body_instruction_index : body_instruction_index
|
||||
+ body_instruction_count
|
||||
],
|
||||
spec.minimum_anchor_bytes,
|
||||
)
|
||||
candidate_entry = find_registry_function_entry(
|
||||
candidate,
|
||||
body_match.rva,
|
||||
@@ -1671,14 +1846,14 @@ def find_constructor_boundary_match(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
spec: SignatureSpec,
|
||||
reference_entry: int,
|
||||
candidate_entry: int,
|
||||
candidate_entries: Sequence[int],
|
||||
) -> SignatureMatch:
|
||||
if reference_entry != spec.reference_rva:
|
||||
raise AnalyzerError(
|
||||
"reference constructor boundary moved outside init-array index 4"
|
||||
)
|
||||
reference_wrapper = disassemble(reference, reference_entry, 1)
|
||||
"""Match a constructor that is one jump to its body.
|
||||
|
||||
The body is found by signature, and the candidate constructor is the one
|
||||
of candidate_entries that jumps to it.
|
||||
"""
|
||||
reference_wrapper = disassemble(reference, spec.reference_rva, 1)
|
||||
reference_target = direct_jump_target(
|
||||
reference_wrapper[0], "reference constructor boundary"
|
||||
)
|
||||
@@ -1686,20 +1861,29 @@ def find_constructor_boundary_match(
|
||||
reference,
|
||||
candidate,
|
||||
SignatureSpec(
|
||||
"constructor-4-target",
|
||||
f"{spec.name}-target",
|
||||
reference_target,
|
||||
spec.instruction_count,
|
||||
),
|
||||
)
|
||||
candidate_wrapper = disassemble(candidate, candidate_entry, 1)
|
||||
candidate_target = direct_jump_target(
|
||||
candidate_wrapper[0], "candidate constructor boundary"
|
||||
)
|
||||
if candidate_target != target_match.rva:
|
||||
found = []
|
||||
for candidate_entry in candidate_entries:
|
||||
try:
|
||||
candidate_wrapper = disassemble(candidate, candidate_entry, 1)
|
||||
candidate_target = direct_jump_target(
|
||||
candidate_wrapper[0], "candidate constructor boundary"
|
||||
)
|
||||
except AnalyzerError:
|
||||
continue
|
||||
if candidate_target == target_match.rva:
|
||||
found.append(
|
||||
SignatureMatch(candidate_entry, reference_wrapper, candidate_wrapper)
|
||||
)
|
||||
if len(found) != 1:
|
||||
raise AnalyzerError(
|
||||
"constructor index 4 no longer targets its verified boundary"
|
||||
f"{spec.name} no longer targets its verified boundary"
|
||||
)
|
||||
return SignatureMatch(candidate_entry, reference_wrapper, candidate_wrapper)
|
||||
return found[0]
|
||||
|
||||
|
||||
def rip_targets(instruction: Any) -> tuple[int, ...]:
|
||||
@@ -1713,6 +1897,161 @@ def rip_targets(instruction: Any) -> tuple[int, ...]:
|
||||
return tuple(targets)
|
||||
|
||||
|
||||
def is_register_operand(operand: Any, register: int) -> bool:
|
||||
return operand.type == capstone_x86.X86_OP_REG and operand.reg == register
|
||||
|
||||
|
||||
def jni_singleton_publication(image: ElfImage, entry: int) -> tuple[Any, ...]:
|
||||
"""Return the instructions that publish the JNI singleton.
|
||||
|
||||
They open its initializer at entry, after a stack frame if it has one:
|
||||
|
||||
lea rax, [rip + OBJECT]
|
||||
xchg qword ptr [rip + SLOT], rax
|
||||
mov qword ptr [rip + OBJECT], rax
|
||||
|
||||
OBJECT is the eight bytes after SLOT.
|
||||
"""
|
||||
for frame in (0, 2):
|
||||
try:
|
||||
decoded = disassemble(image, entry, frame + 3)
|
||||
except AnalyzerError:
|
||||
continue
|
||||
if frame:
|
||||
push, link = decoded[:2]
|
||||
if (
|
||||
push.mnemonic != "push"
|
||||
or len(push.operands) != 1
|
||||
or not is_register_operand(push.operands[0], capstone_x86.X86_REG_RBP)
|
||||
or link.mnemonic != "mov"
|
||||
or len(link.operands) != 2
|
||||
or not is_register_operand(link.operands[0], capstone_x86.X86_REG_RBP)
|
||||
or not is_register_operand(link.operands[1], capstone_x86.X86_REG_RSP)
|
||||
):
|
||||
continue
|
||||
load, exchange, store = decoded[frame:]
|
||||
object_targets = rip_targets(load)
|
||||
slot_targets = rip_targets(exchange)
|
||||
stored_targets = rip_targets(store)
|
||||
if (
|
||||
load.mnemonic == "lea"
|
||||
and len(load.operands) == 2
|
||||
and is_register_operand(load.operands[0], capstone_x86.X86_REG_RAX)
|
||||
and exchange.mnemonic == "xchg"
|
||||
and len(exchange.operands) == 2
|
||||
and exchange.operands[0].size == 8
|
||||
and is_register_operand(exchange.operands[1], capstone_x86.X86_REG_RAX)
|
||||
and store.mnemonic == "mov"
|
||||
and len(store.operands) == 2
|
||||
and store.operands[0].size == 8
|
||||
and is_register_operand(store.operands[1], capstone_x86.X86_REG_RAX)
|
||||
and len(object_targets) == 1
|
||||
and len(slot_targets) == 1
|
||||
and len(stored_targets) == 1
|
||||
and object_targets[0] == stored_targets[0]
|
||||
and object_targets[0] == slot_targets[0] + 8
|
||||
):
|
||||
return decoded[frame:]
|
||||
raise AnalyzerError(
|
||||
f"JNI singleton initializer at {format_rva(entry)} "
|
||||
"does not publish its singleton"
|
||||
)
|
||||
|
||||
|
||||
def find_jni_singleton_match(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
spec: SignatureSpec,
|
||||
candidate_entries: Sequence[int],
|
||||
) -> SignatureMatch:
|
||||
"""Find the JNI singleton initializer among candidate_entries.
|
||||
|
||||
The instructions after the publication follow the singleton's layout, so
|
||||
when a release changes that layout only the publication is matched. The
|
||||
initializer itself runs from the init-array either way.
|
||||
"""
|
||||
try:
|
||||
return find_signature_match(reference, candidate, spec)
|
||||
except AnalyzerError:
|
||||
pass
|
||||
reference_publication = jni_singleton_publication(reference, spec.reference_rva)
|
||||
found = find_signature_match(
|
||||
reference,
|
||||
candidate,
|
||||
SignatureSpec(
|
||||
"jni-singleton-publication",
|
||||
reference_publication[0].address,
|
||||
len(reference_publication),
|
||||
minimum_anchor_bytes=3,
|
||||
),
|
||||
)
|
||||
for entry in candidate_entries:
|
||||
try:
|
||||
publication = jni_singleton_publication(candidate, entry)
|
||||
except AnalyzerError:
|
||||
continue
|
||||
if publication[0].address == found.rva:
|
||||
return SignatureMatch(entry, reference_publication, publication)
|
||||
raise AnalyzerError("JNI singleton initializer is not a leading constructor")
|
||||
|
||||
|
||||
# The native replay starts at this init-array index on x86_64.
|
||||
LEADING_CONSTRUCTOR_BEGIN = 2
|
||||
# The process-load constructor, the JNI singleton initializer and two wiring
|
||||
# entries. A release may put them in any order.
|
||||
LEADING_CONSTRUCTOR_COUNT = 4
|
||||
|
||||
|
||||
def match_leading_constructors(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
constructor_anchors: dict[str, Any],
|
||||
jni_spec: SignatureSpec,
|
||||
reference_init: Sequence[int],
|
||||
candidate_init: Sequence[int],
|
||||
) -> tuple[tuple[int, ...], SignatureMatch]:
|
||||
"""Find each reference leading constructor in the candidate by its code.
|
||||
|
||||
Returns, for each reference leading constructor, the candidate init-array
|
||||
index of the same constructor, both counted from
|
||||
LEADING_CONSTRUCTOR_BEGIN, and the JNI singleton initializer match.
|
||||
"""
|
||||
moved = "constructor moved outside verified init-array boundary"
|
||||
end = LEADING_CONSTRUCTOR_BEGIN + LEADING_CONSTRUCTOR_COUNT
|
||||
if len(reference_init) < end or len(candidate_init) < end:
|
||||
raise AnalyzerError("init-array shape is not derivable")
|
||||
candidate_entries = tuple(candidate_init[LEADING_CONSTRUCTOR_BEGIN:end])
|
||||
candidate_offsets = []
|
||||
jni_match = None
|
||||
for index in range(LEADING_CONSTRUCTOR_BEGIN, end):
|
||||
reference_entry = reference_init[index]
|
||||
name = f"constructor-{index}"
|
||||
if parse_rva(constructor_anchors.get(str(index)), name) != reference_entry:
|
||||
raise AnalyzerError(moved)
|
||||
if reference_entry == jni_spec.reference_rva:
|
||||
match = find_jni_singleton_match(
|
||||
reference, candidate, jni_spec, candidate_entries
|
||||
)
|
||||
jni_match = match
|
||||
else:
|
||||
spec = SignatureSpec(name, reference_entry, 24)
|
||||
if disassemble(reference, reference_entry, 1)[0].mnemonic == "jmp":
|
||||
match = find_constructor_boundary_match(
|
||||
reference, candidate, spec, candidate_entries
|
||||
)
|
||||
else:
|
||||
match = find_signature_match(reference, candidate, spec)
|
||||
if match.rva not in candidate_entries:
|
||||
raise AnalyzerError(moved)
|
||||
candidate_offset = candidate_entries.index(match.rva)
|
||||
if candidate_offset in candidate_offsets:
|
||||
raise AnalyzerError(moved)
|
||||
candidate_offsets.append(candidate_offset)
|
||||
if jni_match is None:
|
||||
raise AnalyzerError("JNI singleton initializer is not a leading constructor")
|
||||
return tuple(candidate_offsets), jni_match
|
||||
|
||||
|
||||
def mapped_rip_target(
|
||||
match: SignatureMatch, reference_target: int, description: str
|
||||
) -> int:
|
||||
@@ -1805,7 +2144,6 @@ def create_signature_specs(
|
||||
bridges = bridge_map(profile)
|
||||
data_seeds = profile["data_seeds"]
|
||||
bootstrap = profile["native_pre_jni_bootstrap"]
|
||||
constructor_rvas = anchors["constructor_rvas"]
|
||||
return [
|
||||
SignatureSpec(
|
||||
"small-allocate",
|
||||
@@ -1870,45 +2208,60 @@ def create_signature_specs(
|
||||
parse_rva(anchors["jni_singleton_initializer_rva"], "JNI singleton anchor"),
|
||||
11,
|
||||
),
|
||||
SignatureSpec(
|
||||
"constructor-2", parse_rva(constructor_rvas["2"], "constructor 2"), 24
|
||||
),
|
||||
SignatureSpec(
|
||||
"constructor-3", parse_rva(constructor_rvas["3"], "constructor 3"), 24
|
||||
),
|
||||
SignatureSpec(
|
||||
"constructor-4",
|
||||
parse_rva(constructor_rvas["4"], "constructor 4"),
|
||||
24,
|
||||
minimum_anchor_bytes=3,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def adjusted_ranges(
|
||||
ranges: list[dict[str, int]], reference_count: int, candidate_count: int
|
||||
def remapped_constructor_ranges(
|
||||
ranges: list[dict[str, int]],
|
||||
candidate_offsets: Sequence[int],
|
||||
reference_count: int,
|
||||
candidate_count: int,
|
||||
) -> list[dict[str, int]]:
|
||||
result = []
|
||||
"""Rewrite the reference constructor ranges for the candidate init-array.
|
||||
|
||||
Each leading constructor keeps its place in or out of the replay under
|
||||
its candidate index, and every later constructor runs.
|
||||
"""
|
||||
cannot_fit = "reference constructor range cannot fit candidate init-array"
|
||||
leading_end = LEADING_CONSTRUCTOR_BEGIN + LEADING_CONSTRUCTOR_COUNT
|
||||
ranges = validated_ranges(ranges, "reference constructor ranges", reference_count)
|
||||
if (
|
||||
ranges[0]["begin"] < LEADING_CONSTRUCTOR_BEGIN
|
||||
or ranges[-1]["begin"] > leading_end
|
||||
or ranges[-1]["end_exclusive"] != reference_count
|
||||
or reference_count <= leading_end
|
||||
or candidate_count <= leading_end
|
||||
):
|
||||
raise AnalyzerError(cannot_fit)
|
||||
runs = [False] * LEADING_CONSTRUCTOR_COUNT
|
||||
for item in ranges:
|
||||
end = (
|
||||
candidate_count
|
||||
if item["end_exclusive"] == reference_count
|
||||
else item["end_exclusive"]
|
||||
)
|
||||
if end > candidate_count:
|
||||
raise AnalyzerError(
|
||||
"reference constructor range cannot fit candidate init-array"
|
||||
)
|
||||
result.append({"begin": item["begin"], "end_exclusive": end})
|
||||
for index in range(item["begin"], min(item["end_exclusive"], leading_end)):
|
||||
runs[candidate_offsets[index - LEADING_CONSTRUCTOR_BEGIN]] = True
|
||||
result = []
|
||||
run_begin = None
|
||||
for offset, run in enumerate(runs):
|
||||
index = LEADING_CONSTRUCTOR_BEGIN + offset
|
||||
if run:
|
||||
if run_begin is None:
|
||||
run_begin = index
|
||||
elif run_begin is not None:
|
||||
result.append({"begin": run_begin, "end_exclusive": index})
|
||||
run_begin = None
|
||||
result.append(
|
||||
{
|
||||
"begin": leading_end if run_begin is None else run_begin,
|
||||
"end_exclusive": candidate_count,
|
||||
}
|
||||
)
|
||||
return validated_ranges(result, "derived constructor ranges", candidate_count)
|
||||
|
||||
|
||||
def derive_profile(
|
||||
def check_derivation_inputs(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
reference_sidecar: dict[str, Any],
|
||||
) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
require_capstone()
|
||||
) -> tuple[tuple[int, ...], tuple[int, ...]]:
|
||||
"""Rejects inputs no derivation may use; returns both init-arrays."""
|
||||
if (
|
||||
reference.build_id != reference_sidecar["elf_build_id"]
|
||||
or reference.sha256 != reference_sidecar["payload_sha256"]
|
||||
@@ -1926,17 +2279,28 @@ def derive_profile(
|
||||
"candidate is missing required JNI exports: "
|
||||
+ ", ".join(sorted(missing_exports))
|
||||
)
|
||||
|
||||
reference_profile = reference_sidecar["profile"]
|
||||
anchors = reference_sidecar["derivation_anchors"]
|
||||
reference_init = reference.init_array_relocations()
|
||||
candidate_init = candidate.init_array_relocations()
|
||||
if len(reference_init) != reference_profile["init_array_count"]:
|
||||
if len(reference_init) != reference_sidecar["profile"]["init_array_count"]:
|
||||
raise AnalyzerError(
|
||||
"reference sidecar init-array count differs from ELF metadata"
|
||||
)
|
||||
if len(candidate_init) < 8:
|
||||
raise AnalyzerError("candidate init-array is unexpectedly short")
|
||||
return reference_init, candidate_init
|
||||
|
||||
|
||||
def derive_profile(
|
||||
reference: ElfImage,
|
||||
candidate: ElfImage,
|
||||
reference_sidecar: dict[str, Any],
|
||||
) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
require_capstone()
|
||||
reference_init, candidate_init = check_derivation_inputs(
|
||||
reference, candidate, reference_sidecar
|
||||
)
|
||||
reference_profile = reference_sidecar["profile"]
|
||||
anchors = reference_sidecar["derivation_anchors"]
|
||||
matches = {}
|
||||
allocate_matches = ()
|
||||
for spec in create_signature_specs(reference_profile, anchors):
|
||||
@@ -1948,13 +2312,14 @@ def derive_profile(
|
||||
matches[spec.name] = find_registry_signature_match(
|
||||
reference, candidate, spec
|
||||
)
|
||||
elif spec.name == "constructor-4":
|
||||
matches[spec.name] = find_constructor_boundary_match(
|
||||
elif spec.name == "jni-singleton-initializer":
|
||||
leading_offsets, matches[spec.name] = match_leading_constructors(
|
||||
reference,
|
||||
candidate,
|
||||
anchors["constructor_rvas"],
|
||||
spec,
|
||||
reference_init[4],
|
||||
candidate_init[4],
|
||||
reference_init,
|
||||
candidate_init,
|
||||
)
|
||||
else:
|
||||
matches[spec.name] = find_signature_match(reference, candidate, spec)
|
||||
@@ -1990,21 +2355,7 @@ def derive_profile(
|
||||
"registry allocator call"
|
||||
)
|
||||
matches["allocate"] = selected_allocate[0]
|
||||
for index in (2, 3, 4):
|
||||
match = matches[f"constructor-{index}"]
|
||||
if (
|
||||
reference_init[index] != match.reference_instructions[0].address
|
||||
or candidate_init[index] != match.rva
|
||||
):
|
||||
raise AnalyzerError(
|
||||
f"constructor {index} moved outside its verified init-array boundary"
|
||||
)
|
||||
singleton_match = matches["jni-singleton-initializer"]
|
||||
if (
|
||||
reference_init[5] != singleton_match.reference_instructions[0].address
|
||||
or candidate_init[5] != singleton_match.rva
|
||||
):
|
||||
raise AnalyzerError("JNI singleton initializer is not constructor index 5")
|
||||
|
||||
candidate_bridge_entries = []
|
||||
for entry in reference_profile["bridge_entries"]:
|
||||
@@ -2075,28 +2426,34 @@ def derive_profile(
|
||||
init_section = candidate.sections[".init_array"]
|
||||
reference_count = reference_profile["init_array_count"]
|
||||
candidate_count = len(candidate_init)
|
||||
constructor_ranges = adjusted_ranges(
|
||||
validated_ranges(
|
||||
reference_profile["constructor_run_ranges"],
|
||||
"reference constructor ranges",
|
||||
reference_count,
|
||||
),
|
||||
constructor_ranges = remapped_constructor_ranges(
|
||||
reference_profile["constructor_run_ranges"],
|
||||
leading_offsets,
|
||||
reference_count,
|
||||
candidate_count,
|
||||
)
|
||||
native_ranges = adjusted_ranges(
|
||||
validated_ranges(
|
||||
reference_profile["native_mimalloc_constructor_run_ranges"],
|
||||
"reference native constructor ranges",
|
||||
reference_count,
|
||||
),
|
||||
native_ranges = remapped_constructor_ranges(
|
||||
reference_profile["native_mimalloc_constructor_run_ranges"],
|
||||
leading_offsets,
|
||||
reference_count,
|
||||
candidate_count,
|
||||
)
|
||||
thread_boundary = reference_profile[
|
||||
reference_thread_boundary = reference_profile[
|
||||
"native_mimalloc_thread_initializer_after_constructor"
|
||||
]
|
||||
if thread_boundary != 2 or not any(
|
||||
if not (
|
||||
LEADING_CONSTRUCTOR_BEGIN
|
||||
<= reference_thread_boundary
|
||||
< LEADING_CONSTRUCTOR_BEGIN + LEADING_CONSTRUCTOR_COUNT
|
||||
):
|
||||
raise AnalyzerError("native allocator TLS boundary is no longer verified")
|
||||
# The thread initializer follows the process-load constructor to its
|
||||
# candidate index.
|
||||
thread_boundary = (
|
||||
LEADING_CONSTRUCTOR_BEGIN
|
||||
+ leading_offsets[reference_thread_boundary - LEADING_CONSTRUCTOR_BEGIN]
|
||||
)
|
||||
if not any(
|
||||
item["begin"] <= thread_boundary < item["end_exclusive"]
|
||||
for item in native_ranges
|
||||
):
|
||||
@@ -2243,13 +2600,22 @@ def analyze(arguments: argparse.Namespace) -> tuple[dict[str, Any], dict[str, An
|
||||
metadata_path = Path(arguments.payload_metadata)
|
||||
sidecar_path = Path(arguments.reference_profile)
|
||||
reference_sidecar = validated_sidecar(sidecar_path)
|
||||
with ElfImage(reference_path) as reference, ElfImage(candidate_path) as candidate:
|
||||
with contextlib.ExitStack() as stack:
|
||||
reference = stack.enter_context(ElfImage(reference_path))
|
||||
candidate = stack.enter_context(ElfImage(candidate_path))
|
||||
fallback = None
|
||||
if arguments.runtime_fallback_lib is not None:
|
||||
with contextlib.suppress(AnalyzerError):
|
||||
fallback = stack.enter_context(
|
||||
ElfImage(Path(arguments.runtime_fallback_lib))
|
||||
)
|
||||
metadata = validated_payload_metadata(metadata_path, candidate_path, candidate)
|
||||
profile, anchors = derive_profile(reference, candidate, reference_sidecar)
|
||||
runtime_compatibility = derive_runtime_compatibility(
|
||||
reference,
|
||||
candidate,
|
||||
tuple(Path(path) for path in arguments.reference_compatibility),
|
||||
fallback,
|
||||
)
|
||||
return output_documents(
|
||||
candidate,
|
||||
@@ -2274,6 +2640,12 @@ def parse_arguments(argv: Sequence[str]) -> argparse.Namespace:
|
||||
metavar="MANIFEST",
|
||||
help="compatibility manifest containing exact reference runtime anchors",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--runtime-fallback-lib",
|
||||
metavar="LIB",
|
||||
help="libroblox.so of another build in the compatibility manifests; "
|
||||
"supplies the FMOD output-device anchors when the reference has none",
|
||||
)
|
||||
parser.add_argument("--candidate-lib", required=True, metavar="LIB")
|
||||
parser.add_argument("--payload-metadata", required=True, metavar="META")
|
||||
parser.add_argument("--output", required=True, metavar="PROFILE")
|
||||
|
||||
@@ -18,12 +18,15 @@ AnyLinuxDependencyRequireContainer() {
|
||||
}
|
||||
|
||||
AnyLinuxDependencySnapshot() {
|
||||
local manifest="$1" release="$2" filename remainder names_json
|
||||
local manifest="$1" release="$2" host_arch="${3:-$(uname -m)}"
|
||||
local filename remainder names_json
|
||||
[[ "${host_arch}" == x86_64 || "${host_arch}" == aarch64 ]] ||
|
||||
AnyLinuxDependencyDie 'unsupported AppImage architecture'
|
||||
local -a names=()
|
||||
local -A seen=()
|
||||
while read -r filename remainder || [[ -n "${filename}" ]]; do
|
||||
[[ -n "${filename}" && "${filename}" != \#* ]] || continue
|
||||
[[ "${filename}" =~ ^[a-z0-9-]+-mini-x86_64\.pkg\.tar\.zst$ &&
|
||||
[[ "${filename}" =~ ^[a-z0-9-]+-mini-${host_arch}\.pkg\.tar\.(zst|xz)$ &&
|
||||
-z "${remainder}" && -z "${seen[${filename}]:-}" ]] ||
|
||||
AnyLinuxDependencyDie 'invalid or duplicate dependency manifest entry'
|
||||
seen["${filename}"]=1
|
||||
@@ -104,11 +107,39 @@ AnyLinuxDownloadDependencies() {
|
||||
AnyLinuxDependencyDie 'dependency downloads failed after 3 snapshots'
|
||||
}
|
||||
|
||||
# Prints the package name and path of each archive that is older than the
|
||||
# installed package.
|
||||
AnyLinuxDependencyDowngrades() {
|
||||
local package name version installed
|
||||
for package in "$@"; do
|
||||
read -r name version < <(pacman -Qp -- "${package}")
|
||||
installed="$(pacman -Q -- "${name}" 2>/dev/null | cut -d ' ' -f 2)" || continue
|
||||
[[ -n "${installed}" ]] || continue
|
||||
if (( $(vercmp "${version}" "${installed}") < 0 )); then
|
||||
printf '%s\t%s\n' "${name}" "${package}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Prints each pkg-config module whose requirements are not met.
|
||||
AnyLinuxDependencyBrokenModules() {
|
||||
local module
|
||||
while read -r module; do
|
||||
pkg-config --exists "${module}" 2>/dev/null || printf '%s\n' "${module}"
|
||||
done < <(pkg-config --list-package-names 2>/dev/null)
|
||||
}
|
||||
|
||||
AnyLinuxDependenciesMain() (
|
||||
AnyLinuxDependencyRequireContainer
|
||||
(( $# == 0 )) || AnyLinuxDependencyDie 'no arguments are supported'
|
||||
readonly ROOT="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
readonly MANIFEST="${ROOT}/packaging/anylinux-dependencies.txt"
|
||||
local host_arch="$(uname -m)" manifest_name
|
||||
case "${host_arch}" in
|
||||
x86_64) manifest_name=anylinux-dependencies.txt ;;
|
||||
aarch64) manifest_name=anylinux-dependencies-aarch64.txt ;;
|
||||
*) AnyLinuxDependencyDie "unsupported AppImage architecture: ${host_arch}" ;;
|
||||
esac
|
||||
readonly MANIFEST="${ROOT}/packaging/${manifest_name}"
|
||||
readonly DOWNLOADS="$(mktemp -d "${TMPDIR:-/tmp}/mocktail-debloated.XXXXXX")"
|
||||
trap 'rm -rf -- "${DOWNLOADS}"' EXIT
|
||||
AnyLinuxDownloadDependencies "${MANIFEST}" "${DOWNLOADS}"
|
||||
@@ -117,7 +148,35 @@ AnyLinuxDependenciesMain() (
|
||||
while IFS=$'\t' read -r digest filename url; do
|
||||
packages+=("${DOWNLOADS}/${filename}")
|
||||
done <"${DOWNLOADS}/dependencies.tsv"
|
||||
pacman -U --noconfirm --needed "${packages[@]}"
|
||||
local broken name package
|
||||
local -a current=() older=() older_names=()
|
||||
local -A is_older=()
|
||||
while IFS=$'\t' read -r name package; do
|
||||
older_names+=("${name}")
|
||||
is_older["${package}"]=1
|
||||
done < <(AnyLinuxDependencyDowngrades "${packages[@]}")
|
||||
for package in "${packages[@]}"; do
|
||||
if [[ -n "${is_older[${package}]:-}" ]]; then
|
||||
older+=("${package}")
|
||||
else
|
||||
current+=("${package}")
|
||||
fi
|
||||
done
|
||||
(( ${#current[@]} == 0 )) || pacman -U --noconfirm --needed "${current[@]}"
|
||||
(( ${#older[@]} > 0 )) || return 0
|
||||
# A reduced package can lag the distribution. If the older version leaves
|
||||
# another package's pkg-config requirements unmet, build with the
|
||||
# distribution's package for that library. Modules that the reduced
|
||||
# packages of the current version already leave unmet do not count.
|
||||
broken="$(AnyLinuxDependencyBrokenModules)"
|
||||
pacman -U --noconfirm --needed "${older[@]}"
|
||||
if [[ "$(AnyLinuxDependencyBrokenModules)" != "${broken}" ]]; then
|
||||
printf '[anylinux-dependencies] reduced packages are too old; restoring %s\n' \
|
||||
"${older_names[*]}" >&2
|
||||
pacman -S --noconfirm "${older_names[@]}"
|
||||
[[ "$(AnyLinuxDependencyBrokenModules)" == "${broken}" ]] ||
|
||||
AnyLinuxDependencyDie 'reduced packages break pkg-config requirements'
|
||||
fi
|
||||
)
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
||||
|
||||
@@ -119,6 +119,7 @@ libyaml
|
||||
fontconfig
|
||||
minizip
|
||||
libplacebo
|
||||
libpng
|
||||
util-linux'
|
||||
INSTALL_ARGS='-S --needed --noconfirm'
|
||||
;;
|
||||
@@ -144,6 +145,7 @@ libyaml
|
||||
fontconfig
|
||||
minizip
|
||||
libplacebo
|
||||
libpng
|
||||
util-linux'
|
||||
if HostUsesMusl; then
|
||||
PACKAGES="$PACKAGES gcompat"
|
||||
@@ -172,6 +174,7 @@ libyaml
|
||||
fontconfig
|
||||
minizip
|
||||
libplacebo
|
||||
libpng
|
||||
coreutils
|
||||
findutils
|
||||
util-linux'
|
||||
|
||||
@@ -207,7 +207,13 @@ EOF
|
||||
"${ANYLINUX_TOOL}" --make-appimage
|
||||
local result="${ANYLINUX_WORK}/image/$(basename -- "${ANYLINUX_OUTPUT}")"
|
||||
[[ -x "${result}" ]] || AnyLinuxDie "quick-sharun did not create the requested AppImage"
|
||||
if [[ -n "${UPINFO:-}" ]]; then
|
||||
[[ -s "${result}.zsync" ]] || AnyLinuxDie "update information was set but no .zsync was generated"
|
||||
fi
|
||||
mv -f -- "${result}" "${ANYLINUX_OUTPUT}"
|
||||
if [[ -f "${result}.zsync" ]]; then
|
||||
mv -fT -- "${result}.zsync" "${ANYLINUX_OUTPUT}.zsync"
|
||||
fi
|
||||
printf '[anylinux] AppImage ready: %s\n' "${ANYLINUX_OUTPUT}" >&2
|
||||
}
|
||||
|
||||
|
||||
@@ -409,9 +409,11 @@ WriteClassicPixbufCache() {
|
||||
Die "classic GdkPixbuf loader cache is unavailable"
|
||||
sed -E \
|
||||
-e 's@^# LoaderDir = .*$@# LoaderDir = lib/plugins/gdk-pixbuf-2.0/2.10.0/loaders@' \
|
||||
-e 's#^"[^"]*/(libpixbufloader[-_][^/"]+\.so)"$#"lib/plugins/gdk-pixbuf-2.0/2.10.0/loaders/\1"#' \
|
||||
-e 's#^"[^"]*/([^/"]+\.so)"$#"lib/plugins/gdk-pixbuf-2.0/2.10.0/loaders/\1"#' \
|
||||
"${source_cache}" >"${destination_cache}"
|
||||
if grep -Eq '^"/(usr|lib|lib64|opt|home|hdd|tmp)/' \
|
||||
# Module records contain only a quoted path. Image signatures such as XPM
|
||||
# can also start with '/' but have additional fields after the string.
|
||||
if grep -Eq '^"/[^"]*"$' \
|
||||
"${destination_cache}"; then
|
||||
Die "GdkPixbuf cache still contains an absolute loader path"
|
||||
fi
|
||||
@@ -663,4 +665,6 @@ Main() {
|
||||
PublishResources
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
||||
Main "$@"
|
||||
fi
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Modified by vii from komaruworld/mocktail. See README "About this fork".
|
||||
# Copyright 2026 Mocktail Project Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Prints the native package version for the current ref. A release tag gives
|
||||
# its own version; anything else gives 0.0.0, which sorts below every release.
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
ref="${1:-${GITHUB_REF_NAME:-}}"
|
||||
version="${ref#v}"
|
||||
|
||||
if [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
printf '%s\n' "${version}"
|
||||
else
|
||||
printf '0.0.0\n'
|
||||
fi
|
||||
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2026 Mocktail Project Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Run the HostAbi deriver and the solver on one update and compare them.
|
||||
|
||||
Usage:
|
||||
python3 roblox_abi_check.py --reference-lib OLD.so \\
|
||||
--reference-profile OLD_PROFILE.json \\
|
||||
--reference-compatibility config/roblox_compatibility.json \\
|
||||
--candidate-lib NEW.so
|
||||
|
||||
Prints every field where the two disagree. Exit status: 0 agree, 1 differ or
|
||||
one side failed, 2 both failed.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from typing import Any, Sequence
|
||||
|
||||
|
||||
def _load_solver():
|
||||
name = "mocktail_roblox_abi_solver"
|
||||
if name in sys.modules:
|
||||
return sys.modules[name]
|
||||
path = Path(__file__).resolve().with_name("roblox_abi_solver.py")
|
||||
specification = importlib.util.spec_from_file_location(name, path)
|
||||
if specification is None or specification.loader is None:
|
||||
raise RuntimeError("cannot load roblox_abi_solver.py")
|
||||
module = importlib.util.module_from_spec(specification)
|
||||
sys.modules[name] = module
|
||||
specification.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
SOLVER = _load_solver()
|
||||
DERIVER = SOLVER.DERIVER
|
||||
AnalyzerError = SOLVER.AnalyzerError
|
||||
format_rva = SOLVER.format_rva
|
||||
|
||||
|
||||
def compare_results(derived: Any, solved: Any, path: str = "") -> list[str]:
|
||||
"""Returns one line for every leaf value where the two results differ."""
|
||||
if isinstance(derived, dict) and isinstance(solved, dict):
|
||||
lines = []
|
||||
for key in sorted(derived.keys() | solved.keys(), key=str):
|
||||
child = f"{path}.{key}" if path else str(key)
|
||||
if key not in solved:
|
||||
lines.append(f"{child}: deriver {derived[key]}, solver missing")
|
||||
elif key not in derived:
|
||||
lines.append(f"{child}: deriver missing, solver {solved[key]}")
|
||||
else:
|
||||
lines.extend(compare_results(derived[key], solved[key], child))
|
||||
return lines
|
||||
if isinstance(derived, list) and isinstance(solved, list) and len(derived) == len(solved):
|
||||
return [
|
||||
line
|
||||
for index, (left, right) in enumerate(zip(derived, solved))
|
||||
for line in compare_results(left, right, f"{path}[{index}]")
|
||||
]
|
||||
return [] if derived == solved else [f"{path}: deriver {derived}, solver {solved}"]
|
||||
|
||||
|
||||
def check_status(
|
||||
derived: Any, solved: Any, deriver_error: str | None, solver_error: str | None
|
||||
) -> tuple[int, list[str]]:
|
||||
"""Exit status and report lines: 0 agree, 1 differ or one failed, 2 both failed."""
|
||||
lines = []
|
||||
if deriver_error is not None:
|
||||
lines.append(f"deriver failed: {deriver_error}")
|
||||
if solver_error is not None:
|
||||
lines.append(f"solver failed: {solver_error}")
|
||||
if deriver_error is not None and solver_error is not None:
|
||||
return 2, lines
|
||||
if deriver_error is not None or solver_error is not None:
|
||||
return 1, lines
|
||||
differences = compare_results(derived, solved)
|
||||
if differences:
|
||||
return 1, differences
|
||||
return 0, ["deriver and solver agree on every field"]
|
||||
|
||||
|
||||
def _solver_runtime_source(source: dict[str, Any]) -> dict[str, Any]:
|
||||
# The deriver's loader returns integers; the solver reads hex strings.
|
||||
result: dict[str, Any] = {}
|
||||
for key, value in source.items():
|
||||
if isinstance(value, dict):
|
||||
result[key] = {
|
||||
field: item if field == "vtable_layout_version" else format_rva(item)
|
||||
for field, item in value.items()
|
||||
}
|
||||
else:
|
||||
result[key] = format_rva(value)
|
||||
return result
|
||||
|
||||
|
||||
def _describe(error: Exception) -> str:
|
||||
if isinstance(error, AnalyzerError):
|
||||
return str(error)
|
||||
return f"{type(error).__name__}: {error}"
|
||||
|
||||
|
||||
def check(arguments: argparse.Namespace) -> int:
|
||||
"""Runs the deriver and the solver on one update and compares them."""
|
||||
sidecar = DERIVER.validated_sidecar(Path(arguments.reference_profile))
|
||||
manifests = [Path(path) for path in arguments.reference_compatibility]
|
||||
cache_dir = Path(arguments.cache_dir) if arguments.cache_dir else None
|
||||
derived = solved = deriver_error = solver_error = None
|
||||
with DERIVER.ElfImage(Path(arguments.reference_lib)) as reference, DERIVER.ElfImage(
|
||||
Path(arguments.candidate_lib)
|
||||
) as candidate:
|
||||
try:
|
||||
profile, anchors = DERIVER.derive_profile(reference, candidate, sidecar)
|
||||
runtime = DERIVER.derive_runtime_compatibility(reference, candidate, manifests)
|
||||
derived = {"profile": profile, "derivation_anchors": anchors, "runtime": runtime}
|
||||
except Exception as error:
|
||||
deriver_error = _describe(error)
|
||||
try:
|
||||
# The input checks are cheap; indexing both libraries is not.
|
||||
SOLVER.check_inputs(reference, candidate, sidecar)
|
||||
solver = SOLVER.Solver(reference, candidate, cache_dir)
|
||||
profile, anchors = solver.derive_profile(sidecar)
|
||||
source = DERIVER.load_reference_runtime_profile(manifests, reference.build_id)
|
||||
runtime = solver.derive_runtime_compatibility(_solver_runtime_source(source))
|
||||
solved = {"profile": profile, "derivation_anchors": anchors, "runtime": runtime}
|
||||
except Exception as error:
|
||||
solver_error = _describe(error)
|
||||
status, lines = check_status(derived, solved, deriver_error, solver_error)
|
||||
for line in lines:
|
||||
print(line)
|
||||
return status
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Run the HostAbi deriver and the solver on one update and compare them"
|
||||
)
|
||||
parser.add_argument("--reference-lib", required=True, metavar="REF")
|
||||
parser.add_argument("--reference-profile", required=True, metavar="REFJSON")
|
||||
parser.add_argument(
|
||||
"--reference-compatibility", action="append", default=[], metavar="MANIFEST"
|
||||
)
|
||||
parser.add_argument("--candidate-lib", required=True, metavar="LIB")
|
||||
parser.add_argument(
|
||||
"--cache-dir",
|
||||
default=str(Path.home() / ".cache" / "mocktail" / "function_index"),
|
||||
help="where function indexes are kept; empty to disable",
|
||||
)
|
||||
arguments = parser.parse_args(sys.argv[1:] if argv is None else argv)
|
||||
try:
|
||||
return check(arguments)
|
||||
except AnalyzerError as error:
|
||||
print(f"roblox-abi-check: error: {error}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,401 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2026 Mocktail Project Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Evidence-scoring solver that finds HostAbi addresses in a new libroblox.
|
||||
|
||||
Each function in both builds is indexed by `roblox_function_index.py`. A
|
||||
reference function is matched through independent clues:
|
||||
|
||||
- the same instruction shape, unique in both builds
|
||||
- callers and callees that are already matched
|
||||
- the strings it references
|
||||
- its data references, shifted by the distance mapped for those addresses
|
||||
- its place between matched neighbours
|
||||
|
||||
A match is accepted only with a score of at least ACCEPT_SCORE and a lead of
|
||||
at least ACCEPT_LEAD over the runner-up. `roblox_abi_targets.py` turns the
|
||||
matches into a profile with the same shape as the one
|
||||
`derive_roblox_host_abi_profile.py` writes, and `roblox_abi_check.py`
|
||||
compares the two on one update.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import bisect
|
||||
import collections
|
||||
from dataclasses import dataclass
|
||||
import difflib
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from typing import Any, Callable, Sequence
|
||||
|
||||
|
||||
def _load_sibling(name: str, file_name: str):
|
||||
if name in sys.modules:
|
||||
return sys.modules[name]
|
||||
path = Path(__file__).resolve().with_name(file_name)
|
||||
specification = importlib.util.spec_from_file_location(name, path)
|
||||
if specification is None or specification.loader is None:
|
||||
raise RuntimeError(f"cannot load {file_name}")
|
||||
module = importlib.util.module_from_spec(specification)
|
||||
sys.modules[name] = module
|
||||
specification.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
INDEX = _load_sibling("mocktail_roblox_function_index", "roblox_function_index.py")
|
||||
TARGETS = _load_sibling("mocktail_roblox_abi_targets", "roblox_abi_targets.py")
|
||||
DERIVER = INDEX.DERIVER
|
||||
FunctionIndex = INDEX.FunctionIndex
|
||||
Instruction = INDEX.Instruction
|
||||
AnalyzerError = DERIVER.AnalyzerError
|
||||
format_rva = DERIVER.format_rva
|
||||
check_inputs = TARGETS.check_inputs
|
||||
validate_fmod_source = TARGETS.validate_fmod_source
|
||||
|
||||
ACCEPT_SCORE = 0.6
|
||||
ACCEPT_LEAD = 0.2
|
||||
# Candidates that get the full, disassembling score after the cheap one.
|
||||
FULL_SCORE_LIMIT = 64
|
||||
# A data address used by more functions than this is too common to narrow
|
||||
# the candidates by itself.
|
||||
XREF_FANOUT_LIMIT = 64
|
||||
# Scores are float sums; a lead that equals ACCEPT_LEAD on paper may be
|
||||
# a few ulps short.
|
||||
_TOLERANCE = 1e-9
|
||||
|
||||
|
||||
def choose_candidate(
|
||||
scored: Sequence[tuple[float, int]], tie_breaker: int | None = None
|
||||
) -> int | None:
|
||||
"""Returns the leading candidate, or None when no lead is clear.
|
||||
|
||||
`tie_breaker` picks among the candidates that clear ACCEPT_SCORE and sit
|
||||
within ACCEPT_LEAD of the best; it cannot lift or overrule any other.
|
||||
"""
|
||||
if not scored:
|
||||
return None
|
||||
ranked = sorted(scored, key=lambda item: item[0], reverse=True)
|
||||
best_score, best = ranked[0]
|
||||
runner_up = ranked[1][0] if len(ranked) > 1 else 0.0
|
||||
if best_score >= ACCEPT_SCORE and best_score - runner_up >= ACCEPT_LEAD - _TOLERANCE:
|
||||
return best
|
||||
tied = {
|
||||
rva for value, rva in ranked
|
||||
if value >= ACCEPT_SCORE and best_score - value < ACCEPT_LEAD - _TOLERANCE
|
||||
}
|
||||
return tie_breaker if tie_breaker in tied else None
|
||||
|
||||
|
||||
def align_instructions(
|
||||
reference_shapes: Sequence[str], candidate_shapes: Sequence[str]
|
||||
) -> dict[int, int]:
|
||||
"""Maps reference instruction indexes to candidate indexes of equal shape."""
|
||||
matcher = difflib.SequenceMatcher(
|
||||
None, reference_shapes, candidate_shapes, autojunk=False
|
||||
)
|
||||
mapping = {}
|
||||
for block in matcher.get_matching_blocks():
|
||||
for offset in range(block.size):
|
||||
mapping[block.a + offset] = block.b + offset
|
||||
return mapping
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Match:
|
||||
rva: int
|
||||
score: float
|
||||
lead: float
|
||||
# "score" when the score alone decided, "vtable" when a slot broke a tie.
|
||||
decided_by: str
|
||||
|
||||
|
||||
def _share(expected: Sequence[Any], present: set[Any]) -> float | None:
|
||||
if not expected:
|
||||
return None
|
||||
return sum(1 for item in expected if item in present) / len(expected)
|
||||
|
||||
|
||||
def _weighted(parts: Sequence[tuple[float | None, float]]) -> float:
|
||||
present = [(value, weight) for value, weight in parts if value is not None]
|
||||
return sum(value * weight for value, weight in present) / sum(
|
||||
weight for _, weight in present
|
||||
)
|
||||
|
||||
|
||||
class Solver(TARGETS.TargetDerivation):
|
||||
def __init__(self, reference: Any, candidate: Any, cache_dir: Path | None = None):
|
||||
self._start(FunctionIndex(reference, cache_dir), FunctionIndex(candidate, cache_dir))
|
||||
|
||||
@classmethod
|
||||
def from_indexes(cls, reference: Any, candidate: Any) -> "Solver":
|
||||
solver = cls.__new__(cls)
|
||||
solver._start(reference, candidate)
|
||||
return solver
|
||||
|
||||
def _start(self, reference: Any, candidate: Any) -> None:
|
||||
self.reference = reference
|
||||
self.candidate = candidate
|
||||
self.pairs: dict[int, int] = {}
|
||||
self._owners: dict[int, int] = {}
|
||||
for start, other in self._shape_anchors().items():
|
||||
self._pair(start, other)
|
||||
self._propagate_calls()
|
||||
self.data_map = self._map_data_references()
|
||||
self.matches: dict[str, Match] = {}
|
||||
self._claimed: dict[int, int] = {}
|
||||
|
||||
def _pair(self, start: int, other: int) -> None:
|
||||
"""Pairs two functions, dropping any pair that held either one."""
|
||||
owner = self._owners.get(other)
|
||||
if owner is not None and owner != start:
|
||||
del self.pairs[owner]
|
||||
previous = self.pairs.get(start)
|
||||
if previous is not None and previous != other:
|
||||
del self._owners[previous]
|
||||
self.pairs[start] = other
|
||||
self._owners[other] = start
|
||||
|
||||
def _shape_anchors(self) -> dict[int, int]:
|
||||
reference_hashes = collections.defaultdict(list)
|
||||
candidate_hashes = collections.defaultdict(list)
|
||||
for start, info in self.reference.functions.items():
|
||||
reference_hashes[info.shape_hash].append(start)
|
||||
for start, info in self.candidate.functions.items():
|
||||
candidate_hashes[info.shape_hash].append(start)
|
||||
pairs = {}
|
||||
for shape_hash, starts in reference_hashes.items():
|
||||
others = candidate_hashes.get(shape_hash, ())
|
||||
if len(starts) == 1 and len(others) == 1:
|
||||
pairs[starts[0]] = others[0]
|
||||
return pairs
|
||||
|
||||
def _propagate_calls(self) -> None:
|
||||
# Matched functions with as many calls pair their callees in order.
|
||||
reference, candidate = self.reference.functions, self.candidate.functions
|
||||
pending = list(self.pairs.items())
|
||||
while pending:
|
||||
discovered = []
|
||||
for reference_start, candidate_start in pending:
|
||||
reference_calls = reference[reference_start].calls
|
||||
candidate_calls = candidate[candidate_start].calls
|
||||
if len(reference_calls) != len(candidate_calls):
|
||||
continue
|
||||
for callee, other in zip(reference_calls, candidate_calls):
|
||||
if (
|
||||
callee in self.pairs
|
||||
or other in self._owners
|
||||
or callee not in reference
|
||||
or other not in candidate
|
||||
):
|
||||
continue
|
||||
size = reference[callee].size
|
||||
if abs(size - candidate[other].size) <= max(16, size // 4):
|
||||
self._pair(callee, other)
|
||||
discovered.append((callee, other))
|
||||
pending = discovered
|
||||
|
||||
def _map_data_references(self) -> dict[int, int]:
|
||||
votes: dict[int, collections.Counter] = collections.defaultdict(collections.Counter)
|
||||
for reference_start, candidate_start in self.pairs.items():
|
||||
reference_refs = self.reference.functions[reference_start].refs
|
||||
candidate_refs = self.candidate.functions[candidate_start].refs
|
||||
if len(reference_refs) == len(candidate_refs):
|
||||
for reference_target, candidate_target in zip(reference_refs, candidate_refs):
|
||||
votes[reference_target][candidate_target] += 1
|
||||
return {target: counter.most_common(1)[0][0] for target, counter in votes.items()}
|
||||
|
||||
def _gap_candidates(self, start: int) -> list[int]:
|
||||
starts = self.reference.starts
|
||||
index = bisect.bisect_left(starts, start)
|
||||
below = next(
|
||||
(self.pairs[starts[i]] for i in range(index - 1, -1, -1) if starts[i] in self.pairs),
|
||||
self.candidate.text.address,
|
||||
)
|
||||
above = next(
|
||||
(self.pairs[starts[i]] for i in range(index + 1, len(starts)) if starts[i] in self.pairs),
|
||||
self.candidate.text.address + self.candidate.text.size,
|
||||
)
|
||||
if above <= below:
|
||||
return []
|
||||
low = bisect.bisect_left(self.candidate.starts, below)
|
||||
high = bisect.bisect_right(self.candidate.starts, above)
|
||||
return self.candidate.starts[low:high]
|
||||
|
||||
def _neighbour_candidates(self, start: int) -> set[int]:
|
||||
found = set()
|
||||
for callee in self.reference.functions[start].calls:
|
||||
if callee in self.pairs:
|
||||
found.update(self.candidate.callers.get(self.pairs[callee], ()))
|
||||
for caller in self.reference.callers.get(start, ()):
|
||||
if caller in self.pairs:
|
||||
found.update(
|
||||
target
|
||||
for target in self.candidate.functions[self.pairs[caller]].calls
|
||||
if target in self.candidate.functions
|
||||
)
|
||||
return found
|
||||
|
||||
def _pattern_candidates(self, start: int) -> set[int]:
|
||||
# Data a function touches usually moves as one block, so its
|
||||
# references shifted by a mapped distance find it in the candidate.
|
||||
refs = set(self.reference.functions[start].refs)
|
||||
distances = collections.Counter(
|
||||
self.data_map[target] - target for target in refs if target in self.data_map
|
||||
)
|
||||
# A common address adds a vote but cannot bring in a candidate alone.
|
||||
votes = collections.Counter()
|
||||
found_by_rare = set()
|
||||
for target in refs:
|
||||
users = set()
|
||||
for distance, _ in distances.most_common(3):
|
||||
found = self.candidate.data_users.get(target + distance, ())
|
||||
users.update(found)
|
||||
if len(found) <= XREF_FANOUT_LIMIT:
|
||||
found_by_rare.update(found)
|
||||
votes.update(users)
|
||||
needed = max(1, len(refs) // 2)
|
||||
return {user for user in found_by_rare if votes[user] >= needed}
|
||||
|
||||
def _graph_score(self, start: int, other: int) -> float:
|
||||
reference = self.reference.functions[start]
|
||||
candidate = self.candidate.functions[other]
|
||||
size = min(reference.size, candidate.size) / max(reference.size, candidate.size)
|
||||
calls = [self.pairs[c] for c in reference.calls if c in self.pairs]
|
||||
callers = [self.pairs[c] for c in self.reference.callers.get(start, ()) if c in self.pairs]
|
||||
data = [self.data_map[t] for t in reference.refs if t in self.data_map]
|
||||
return _weighted(
|
||||
(
|
||||
(size, 1.0),
|
||||
(_share(calls, set(candidate.calls)), 2.0),
|
||||
(_share(callers, set(self.candidate.callers.get(other, ()))), 2.0),
|
||||
(_share(data, set(candidate.refs)), 2.0),
|
||||
)
|
||||
)
|
||||
|
||||
def _full_score(self, start: int, other: int, graph: float) -> float:
|
||||
similarity = difflib.SequenceMatcher(
|
||||
None, self.reference.shapes(start), self.candidate.shapes(other), autojunk=False
|
||||
).ratio()
|
||||
strings = [
|
||||
text
|
||||
for text in map(self.reference.string_at, self.reference.functions[start].refs)
|
||||
if text is not None
|
||||
]
|
||||
candidate_strings = set(
|
||||
map(self.candidate.string_at, self.candidate.functions[other].refs)
|
||||
)
|
||||
return _weighted(
|
||||
(
|
||||
(similarity, 3.0),
|
||||
(_share(strings, candidate_strings), 2.0),
|
||||
(graph, 5.0),
|
||||
)
|
||||
)
|
||||
|
||||
def match_function(
|
||||
self,
|
||||
name: str,
|
||||
start: int,
|
||||
contract: Callable[[Any, int], bool] | None = None,
|
||||
vtable_slot: int | None = None,
|
||||
) -> int:
|
||||
"""Matches one reference function.
|
||||
|
||||
A contract drops candidates outright. `vtable_slot` is the candidate
|
||||
that sits in the matching slot of an already located vtable; it only
|
||||
breaks a tie between candidates that pass on their own evidence.
|
||||
"""
|
||||
if start not in self.reference.functions:
|
||||
raise AnalyzerError(f"reference {name} is not a function start")
|
||||
if name in self.matches:
|
||||
return self.matches[name].rva
|
||||
candidates = set(self._gap_candidates(start))
|
||||
candidates |= self._neighbour_candidates(start)
|
||||
candidates |= self._pattern_candidates(start)
|
||||
if start in self.pairs:
|
||||
candidates.add(self.pairs[start])
|
||||
if vtable_slot in self.candidate.functions:
|
||||
candidates.add(vtable_slot)
|
||||
size = self.reference.functions[start].size
|
||||
candidates = {
|
||||
other
|
||||
for other in candidates
|
||||
if self._claimed.get(other, start) == start
|
||||
and self.candidate.functions[other].size <= 8 * size + 64
|
||||
and (contract is None or contract(self.candidate.image, other))
|
||||
}
|
||||
graph = {other: self._graph_score(start, other) for other in candidates}
|
||||
shortlist = sorted(candidates, key=graph.__getitem__, reverse=True)[:FULL_SCORE_LIMIT]
|
||||
if vtable_slot in candidates and vtable_slot not in shortlist:
|
||||
shortlist.append(vtable_slot)
|
||||
scored = [(self._full_score(start, other, graph[other]), other) for other in shortlist]
|
||||
chosen = choose_candidate(scored)
|
||||
decided_by = "score"
|
||||
if chosen is None and vtable_slot is not None:
|
||||
chosen = choose_candidate(scored, tie_breaker=vtable_slot)
|
||||
decided_by = "vtable"
|
||||
if chosen is None:
|
||||
ranked = sorted(scored, reverse=True)[:2]
|
||||
raise AnalyzerError(
|
||||
f"{name} has no clear candidate: "
|
||||
+ ", ".join(f"{format_rva(rva)}={value:.2f}" for value, rva in ranked)
|
||||
)
|
||||
chosen_score = next(value for value, other in scored if other == chosen)
|
||||
runner_up = max((value for value, other in scored if other != chosen), default=0.0)
|
||||
self.matches[name] = Match(chosen, chosen_score, chosen_score - runner_up, decided_by)
|
||||
self._claimed[chosen] = start
|
||||
self._pair(start, chosen)
|
||||
return chosen
|
||||
|
||||
def _aligned(self, name: str, start: int) -> tuple[list[Instruction], list[Instruction], dict[int, int]]:
|
||||
other = self.match_function(name, start)
|
||||
reference = self.reference.instructions(start)
|
||||
candidate = self.candidate.instructions(other)
|
||||
mapping = align_instructions(
|
||||
[item.shape for item in reference], [item.shape for item in candidate]
|
||||
)
|
||||
return reference, candidate, mapping
|
||||
|
||||
def map_instruction(self, name: str, rva: int) -> int:
|
||||
start = self.reference.containing(rva)
|
||||
if start is None:
|
||||
raise AnalyzerError(f"reference {name} is outside every function")
|
||||
reference, candidate, mapping = self._aligned(f"{name} function", start)
|
||||
index = next((i for i, item in enumerate(reference) if item.address == rva), None)
|
||||
if index is None or index not in mapping:
|
||||
raise AnalyzerError(f"{name} instruction has no counterpart")
|
||||
return candidate[mapping[index]].address
|
||||
|
||||
def map_data(self, name: str, function_name: str, start: int, target: int) -> int:
|
||||
reference, candidate, mapping = self._aligned(function_name, start)
|
||||
found = set()
|
||||
for index, item in enumerate(reference):
|
||||
if target not in item.rip_targets:
|
||||
continue
|
||||
if index not in mapping:
|
||||
raise AnalyzerError(f"{name} reference instruction has no counterpart")
|
||||
other = candidate[mapping[index]]
|
||||
if len(other.rip_targets) != len(item.rip_targets):
|
||||
raise AnalyzerError(f"{name} RIP-relative operand count changed")
|
||||
found.update(
|
||||
other.rip_targets[position]
|
||||
for position, value in enumerate(item.rip_targets)
|
||||
if value == target
|
||||
)
|
||||
if len(found) != 1:
|
||||
raise AnalyzerError(f"{name} has no unique mapped data address")
|
||||
return found.pop()
|
||||
@@ -0,0 +1,375 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2026 Mocktail Project Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""HostAbi targets that `roblox_abi_solver.py` derives from its matches.
|
||||
|
||||
`TargetDerivation` turns matched functions into the HostAbi profile, the
|
||||
derivation anchors and the runtime compatibility block, in the shape that
|
||||
`derive_roblox_host_abi_profile.py` writes. It reuses the deriver's input
|
||||
checks, contracts and post-processing.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from typing import Any, Callable
|
||||
|
||||
|
||||
def _load_index():
|
||||
name = "mocktail_roblox_function_index"
|
||||
if name in sys.modules:
|
||||
return sys.modules[name]
|
||||
path = Path(__file__).resolve().with_name("roblox_function_index.py")
|
||||
specification = importlib.util.spec_from_file_location(name, path)
|
||||
if specification is None or specification.loader is None:
|
||||
raise RuntimeError("cannot load roblox_function_index.py")
|
||||
module = importlib.util.module_from_spec(specification)
|
||||
sys.modules[name] = module
|
||||
specification.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
DERIVER = _load_index().DERIVER
|
||||
AnalyzerError = DERIVER.AnalyzerError
|
||||
format_rva = DERIVER.format_rva
|
||||
FMOD_OUTPUT_FIELDS = DERIVER.FMOD_OUTPUT_FIELDS
|
||||
FMOD_INPUT_FIELDS = DERIVER.FMOD_INPUT_FIELDS
|
||||
fmod_slots = DERIVER.fmod_vtable_slots
|
||||
|
||||
|
||||
def check_inputs(reference: Any, candidate: Any, reference_sidecar: dict[str, Any]) -> None:
|
||||
"""Applies the deriver's identity and preflight checks to both builds."""
|
||||
DERIVER.check_derivation_inputs(reference, candidate, reference_sidecar)
|
||||
|
||||
|
||||
def validate_fmod_source(source: Any) -> int:
|
||||
"""Checks a reference FMOD bridge the way the deriver does; returns its layout."""
|
||||
if (
|
||||
not isinstance(source, dict)
|
||||
or not FMOD_OUTPUT_FIELDS <= source.keys()
|
||||
or source.keys() - FMOD_OUTPUT_FIELDS - set(FMOD_INPUT_FIELDS) - {"vtable_layout_version"}
|
||||
):
|
||||
raise AnalyzerError("reference FMOD output-device profile is incomplete")
|
||||
present = [field for field in FMOD_INPUT_FIELDS if field in source]
|
||||
if present and len(present) != len(FMOD_INPUT_FIELDS):
|
||||
raise AnalyzerError("reference FMOD input profile is incomplete")
|
||||
layout = source.get("vtable_layout_version", 1)
|
||||
if type(layout) is not int or layout not in (1, 2):
|
||||
raise AnalyzerError("reference FMOD vtable layout is unsupported")
|
||||
return layout
|
||||
|
||||
|
||||
class TargetDerivation:
|
||||
"""Mixin for `Solver`: needs `reference`, `candidate`, `matches`,
|
||||
`match_function`, `map_data` and `map_instruction`."""
|
||||
|
||||
def _check_registry_allocator(
|
||||
self,
|
||||
reference_registry: int,
|
||||
candidate_registry: int,
|
||||
reference_allocate: int,
|
||||
candidate_allocate: int,
|
||||
) -> None:
|
||||
# The registry initializer's tenth instruction calls the allocator bridge.
|
||||
for index, start, allocate, side in (
|
||||
(self.reference, reference_registry, reference_allocate, "reference"),
|
||||
(self.candidate, candidate_registry, candidate_allocate, "candidate"),
|
||||
):
|
||||
code = index.instructions(start)
|
||||
if len(code) <= 9 or code[9].shape != "call" or code[9].branch_target != allocate:
|
||||
raise AnalyzerError(
|
||||
f"{side} registry initializer does not call its allocator bridge"
|
||||
)
|
||||
|
||||
def derive_profile(
|
||||
self, reference_sidecar: dict[str, Any]
|
||||
) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
reference_profile = reference_sidecar["profile"]
|
||||
anchors = reference_sidecar["derivation_anchors"]
|
||||
DERIVER.validate_profile_shape(reference_profile, anchors)
|
||||
reference_image = self.reference.image
|
||||
candidate_image = self.candidate.image
|
||||
check_inputs(reference_image, candidate_image, reference_sidecar)
|
||||
parse = DERIVER.parse_rva
|
||||
bridges = []
|
||||
found = {}
|
||||
for entry in reference_profile["bridge_entries"]:
|
||||
rva = self.match_function(entry["label"], parse(entry["rva"], entry["label"]))
|
||||
found[entry["label"]] = rva
|
||||
bridges.append({"rva": format_rva(rva), "kind": entry["kind"], "label": entry["label"]})
|
||||
|
||||
seeds = reference_profile["data_seeds"]
|
||||
arena_initializer = parse(seeds["arena_initializer"], "arena initializer")
|
||||
thread_initializer = parse(seeds["allocator_thread_initializer"], "thread initializer")
|
||||
self.match_function("arena-initializer", arena_initializer)
|
||||
self.match_function("allocator-thread-initializer", thread_initializer)
|
||||
|
||||
bootstrap = reference_profile["native_pre_jni_bootstrap"]
|
||||
DERIVER.validate_reference_registry_slot(reference_image, bootstrap)
|
||||
registry = self.match_function(
|
||||
"registry-initializer", parse(bootstrap["registry_initializer"], "registry")
|
||||
)
|
||||
reference_allocate = parse(
|
||||
DERIVER.bridge_map(reference_profile)["allocate"]["rva"], "reference allocate"
|
||||
)
|
||||
self._check_registry_allocator(
|
||||
parse(bootstrap["registry_initializer"], "registry"),
|
||||
registry, reference_allocate, found["allocate"],
|
||||
)
|
||||
registry_slot = DERIVER.derive_registry_slot(candidate_image, registry)
|
||||
|
||||
reference_init = reference_image.init_array_relocations()
|
||||
candidate_init = candidate_image.init_array_relocations()
|
||||
begin = DERIVER.LEADING_CONSTRUCTOR_BEGIN
|
||||
count = DERIVER.LEADING_CONSTRUCTOR_COUNT
|
||||
leading = candidate_init[begin : begin + count]
|
||||
offsets = []
|
||||
for index in range(begin, begin + count):
|
||||
expected = parse(anchors["constructor_rvas"][str(index)], f"constructor {index}")
|
||||
if reference_init[index] != expected:
|
||||
raise AnalyzerError(f"reference constructor {index} differs from its anchor")
|
||||
rva = self.match_function(f"constructor-{index}", expected)
|
||||
if leading.count(rva) != 1:
|
||||
raise AnalyzerError(f"constructor {index} left the leading constructors")
|
||||
offsets.append(leading.index(rva))
|
||||
if sorted(offsets) != list(range(count)):
|
||||
raise AnalyzerError("leading constructors do not map one to one")
|
||||
|
||||
singleton = parse(anchors["jni_singleton_initializer_rva"], "JNI singleton")
|
||||
jni_singleton = self.match_function("jni-singleton-initializer", singleton)
|
||||
allocator_anchor = parse(anchors["allocator_object_initializer_rva"], "allocator anchor")
|
||||
empty_anchor = parse(anchors["empty_string_initializer_rva"], "empty string anchor")
|
||||
allocator_function = self.reference.containing(allocator_anchor)
|
||||
empty_function = self.reference.containing(empty_anchor)
|
||||
if allocator_function is None or empty_function is None:
|
||||
raise AnalyzerError("reference anchor is outside every function")
|
||||
|
||||
slots = {
|
||||
"allocator_object_slot": self.map_data(
|
||||
"allocator object slot", "allocator-object-initializer function",
|
||||
allocator_function, parse(seeds["allocator_object_slot"], "allocator slot"),
|
||||
),
|
||||
"empty_string_slot": self.map_data(
|
||||
"empty string slot", "empty-string-initializer function",
|
||||
empty_function, parse(seeds["empty_string_slot"], "empty string slot"),
|
||||
),
|
||||
"jni_singleton_slot": self.map_data(
|
||||
"JNI singleton slot", "jni-singleton-initializer",
|
||||
singleton, parse(seeds["jni_singleton_slot"], "JNI singleton slot"),
|
||||
),
|
||||
"arena_guard_slot": self.map_data(
|
||||
"arena guard slot", "arena-initializer",
|
||||
arena_initializer, parse(seeds["arena_guard_slot"], "arena guard slot"),
|
||||
),
|
||||
"arena_table_slot": self.map_data(
|
||||
"arena table slot", "usable-size",
|
||||
parse(DERIVER.bridge_map(reference_profile)["usable-size"]["rva"], "usable size"),
|
||||
parse(seeds["arena_table_slot"], "arena table slot"),
|
||||
),
|
||||
}
|
||||
for slot in slots.values():
|
||||
candidate_image.require_writable_rva(slot, 8)
|
||||
|
||||
candidate_count = len(candidate_init)
|
||||
reference_count = reference_profile["init_array_count"]
|
||||
boundary = reference_profile["native_mimalloc_thread_initializer_after_constructor"]
|
||||
if not begin <= boundary < begin + count:
|
||||
raise AnalyzerError("native allocator TLS boundary is no longer verified")
|
||||
thread_boundary = begin + offsets[boundary - begin]
|
||||
native_ranges = DERIVER.remapped_constructor_ranges(
|
||||
reference_profile["native_mimalloc_constructor_run_ranges"],
|
||||
offsets, reference_count, candidate_count,
|
||||
)
|
||||
if not any(item["begin"] <= thread_boundary < item["end_exclusive"] for item in native_ranges):
|
||||
raise AnalyzerError("native allocator TLS boundary is no longer verified")
|
||||
profile = {
|
||||
"elf_build_id": candidate_image.build_id,
|
||||
"bridge_entries": bridges,
|
||||
"data_seeds": {
|
||||
"allocator_object_slot": format_rva(slots["allocator_object_slot"]),
|
||||
"empty_string_slot": format_rva(slots["empty_string_slot"]),
|
||||
"jni_singleton_slot": format_rva(slots["jni_singleton_slot"]),
|
||||
"jni_singleton_bytes": seeds["jni_singleton_bytes"],
|
||||
"arena_initializer": format_rva(self.matches["arena-initializer"].rva),
|
||||
"allocator_thread_initializer": format_rva(
|
||||
self.matches["allocator-thread-initializer"].rva
|
||||
),
|
||||
"arena_guard_slot": format_rva(slots["arena_guard_slot"]),
|
||||
"arena_table_slot": format_rva(slots["arena_table_slot"]),
|
||||
"arena_table_slot_count": seeds["arena_table_slot_count"],
|
||||
},
|
||||
"native_allocator": {
|
||||
"allocate": format_rva(found["allocate"]),
|
||||
"deallocate": format_rva(found["free"]),
|
||||
},
|
||||
"init_array_offset": format_rva(candidate_image.sections[".init_array"].address),
|
||||
"init_array_count": candidate_count,
|
||||
"constructor_run_ranges": DERIVER.remapped_constructor_ranges(
|
||||
reference_profile["constructor_run_ranges"],
|
||||
offsets, reference_count, candidate_count,
|
||||
),
|
||||
"native_mimalloc_constructor_run_ranges": native_ranges,
|
||||
"native_mimalloc_thread_initializer_after_constructor": thread_boundary,
|
||||
"native_pre_jni_bootstrap": {
|
||||
"registry_initializer": format_rva(registry),
|
||||
"registry_slot": format_rva(registry_slot),
|
||||
},
|
||||
"default_allocator_strategy": "native_mimalloc",
|
||||
}
|
||||
derived_anchors = {
|
||||
"signature_version": 1,
|
||||
"allocator_object_initializer_rva": format_rva(
|
||||
self.map_instruction("allocator-object-initializer", allocator_anchor)
|
||||
),
|
||||
"empty_string_initializer_rva": format_rva(
|
||||
self.map_instruction("empty-string-initializer", empty_anchor)
|
||||
),
|
||||
"jni_singleton_initializer_rva": format_rva(jni_singleton),
|
||||
"constructor_rvas": {
|
||||
str(index): format_rva(candidate_init[index])
|
||||
for index in range(begin, begin + count)
|
||||
},
|
||||
}
|
||||
DERIVER.validate_profile_shape(profile, derived_anchors)
|
||||
return profile, derived_anchors
|
||||
|
||||
def derive_runtime_compatibility(self, source: dict[str, Any]) -> dict[str, Any]:
|
||||
result: dict[str, Any] = {}
|
||||
fullscreen = source.get("user_game_settings_fullscreen_setter_rva")
|
||||
if fullscreen is not None:
|
||||
reference_setter = DERIVER.parse_rva(fullscreen, "fullscreen setter")
|
||||
if not DERIVER.has_fullscreen_setter_contract(self.reference.image, reference_setter):
|
||||
raise AnalyzerError("reference fullscreen setter contract changed")
|
||||
setter = self.match_function(
|
||||
"fullscreen-setter", reference_setter, DERIVER.has_fullscreen_setter_contract
|
||||
)
|
||||
result["user_game_settings_fullscreen_setter_rva"] = format_rva(setter)
|
||||
fmod = source.get("fmod_output_device_bridge")
|
||||
if fmod is not None:
|
||||
result["fmod_output_device_bridge"] = self._derive_fmod_bridge(fmod)
|
||||
return result
|
||||
|
||||
def _derive_fmod_bridge(self, source: dict[str, Any]) -> dict[str, Any]:
|
||||
layout = validate_fmod_source(source)
|
||||
has_input = FMOD_INPUT_FIELDS[0] in source
|
||||
slots = fmod_slots(layout, has_input)
|
||||
parse = DERIVER.parse_rva
|
||||
vtable = parse(source["vtable_rva"], "FMOD vtable")
|
||||
reference_relocations = DERIVER.relative_relocation_map(self.reference.image)
|
||||
methods = {}
|
||||
unresolved = []
|
||||
for field, slot in slots.items():
|
||||
method = parse(source[field], field)
|
||||
if reference_relocations.get(vtable + slot * 8) != method:
|
||||
raise AnalyzerError("reference FMOD vtable does not match its methods")
|
||||
try:
|
||||
methods[field] = self.match_function(
|
||||
f"fmod-{field}", method, self._fmod_contract(layout, field)
|
||||
)
|
||||
except AnalyzerError:
|
||||
unresolved.append(field)
|
||||
string_constructor = parse(source["string_constructor_rva"], "FMOD string constructor")
|
||||
if not DERIVER.has_fmod_string_constructor_contract(self.reference.image, string_constructor):
|
||||
raise AnalyzerError("reference FMOD string constructor contract changed")
|
||||
candidate_string_constructor = self.match_function(
|
||||
"fmod-string-constructor",
|
||||
string_constructor,
|
||||
DERIVER.has_fmod_string_constructor_contract,
|
||||
)
|
||||
|
||||
relocations = DERIVER.relative_relocation_map(self.candidate.image)
|
||||
located = self._locate_fmod_vtables(relocations, methods)
|
||||
vtables = sorted({vtable for vtable, _ in located})
|
||||
if len(vtables) != 1:
|
||||
raise AnalyzerError(f"FMOD output vtable matched {len(vtables)} candidate locations")
|
||||
# The located vtable breaks ties for the methods that did not resolve.
|
||||
# Count and info share slots 5 and 6 in both layouts, so the vtable can
|
||||
# fit both; exactly one layout must then hold every method.
|
||||
solutions = []
|
||||
for located_vtable, target_layout in located:
|
||||
target_slots = fmod_slots(target_layout, has_input)
|
||||
resolved = dict(methods)
|
||||
try:
|
||||
for field in unresolved:
|
||||
resolved[field] = self.match_function(
|
||||
f"fmod-{field}",
|
||||
parse(source[field], field),
|
||||
self._fmod_contract(target_layout, field),
|
||||
relocations.get(located_vtable + target_slots[field] * 8),
|
||||
)
|
||||
except AnalyzerError:
|
||||
continue
|
||||
if self._locate_fmod_vtables(relocations, resolved) != [
|
||||
(located_vtable, target_layout)
|
||||
]:
|
||||
continue
|
||||
if target_layout == 2 and not DERIVER.has_fmod_device_lists_select_contract(
|
||||
self.candidate.image, resolved["select_method_rva"]
|
||||
):
|
||||
continue
|
||||
solutions.append((located_vtable, target_layout, target_slots, resolved))
|
||||
if len(solutions) != 1:
|
||||
raise AnalyzerError(f"FMOD output vtable holds every method in {len(solutions)} layouts")
|
||||
located_vtable, target_layout, target_slots, methods = solutions[0]
|
||||
self.candidate.image.require_relro_rva(
|
||||
located_vtable, (max(target_slots.values()) + 1) * 8
|
||||
)
|
||||
result = {"vtable_rva": format_rva(located_vtable)}
|
||||
result["string_constructor_rva"] = format_rva(candidate_string_constructor)
|
||||
result.update((field, format_rva(rva)) for field, rva in methods.items())
|
||||
if target_layout != 1:
|
||||
result["vtable_layout_version"] = target_layout
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def _fmod_contract(layout: int, field: str) -> Callable[[Any, int], bool] | None:
|
||||
if layout == 2 and field == "select_method_rva":
|
||||
return DERIVER.has_fmod_device_lists_select_contract
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _locate_fmod_vtables(
|
||||
relocations: dict[int, int], methods: dict[str, int]
|
||||
) -> list[tuple[int, int]]:
|
||||
"""Returns (vtable, layout) for each vtable holding every method."""
|
||||
located = []
|
||||
for layout in (1, 2):
|
||||
slots = fmod_slots(layout, True)
|
||||
held = {slots[field]: rva for field, rva in methods.items()}
|
||||
located.extend(
|
||||
(vtable, layout)
|
||||
for vtable in TargetDerivation._vtables_holding(relocations, held)
|
||||
)
|
||||
return sorted(located)
|
||||
|
||||
@staticmethod
|
||||
def _vtables_holding(relocations: dict[int, int], methods: dict[int, int]) -> list[int]:
|
||||
"""Returns every vtable whose slots hold all of `methods`."""
|
||||
if not methods:
|
||||
raise AnalyzerError("no vtable method was matched")
|
||||
slot, method = next(iter(methods.items()))
|
||||
return sorted(
|
||||
offset - slot * 8
|
||||
for offset, value in relocations.items()
|
||||
if value == method
|
||||
and offset >= slot * 8
|
||||
and (offset - slot * 8) % 8 == 0
|
||||
and all(
|
||||
relocations.get(offset - slot * 8 + index * 8) == rva
|
||||
for index, rva in methods.items()
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,291 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2026 Mocktail Project Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Function index of one libroblox image for `roblox_abi_solver.py`.
|
||||
|
||||
Every function listed in `.eh_frame_hdr` is decoded once and reduced to a
|
||||
normalized instruction shape, its direct calls and its RIP-relative data
|
||||
references. Shapes drop branch targets, RIP displacements and immediates of
|
||||
0x1000 and above, so a function moved by the linker keeps its shape.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import bisect
|
||||
import collections
|
||||
from dataclasses import dataclass
|
||||
import gzip
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
from typing import Any
|
||||
|
||||
|
||||
def _load_deriver():
|
||||
name = "mocktail_host_abi_deriver_for_solver"
|
||||
if name in sys.modules:
|
||||
return sys.modules[name]
|
||||
path = Path(__file__).resolve().with_name("derive_roblox_host_abi_profile.py")
|
||||
specification = importlib.util.spec_from_file_location(name, path)
|
||||
if specification is None or specification.loader is None:
|
||||
raise RuntimeError("cannot load the HostAbi deriver")
|
||||
module = importlib.util.module_from_spec(specification)
|
||||
sys.modules[name] = module
|
||||
specification.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
DERIVER = _load_deriver()
|
||||
AnalyzerError = DERIVER.AnalyzerError
|
||||
|
||||
_RIP_OPERAND = re.compile(r"\[rip ([+-]) (0x[0-9a-f]+|\d+)\]")
|
||||
_IMMEDIATE = re.compile(r"0x[0-9a-f]+|\b\d+\b")
|
||||
# Smaller immediates are offsets and flags that stay put between builds.
|
||||
# Larger ones are addresses and sizes that move.
|
||||
_STABLE_IMMEDIATE_LIMIT = 0x1000
|
||||
|
||||
|
||||
def _stable_immediate(match: re.Match) -> str:
|
||||
return "I" if int(match.group(0), 0) >= _STABLE_IMMEDIATE_LIMIT else match.group(0)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Instruction:
|
||||
address: int
|
||||
shape: str
|
||||
rip_targets: tuple[int, ...]
|
||||
branch_target: int | None
|
||||
|
||||
|
||||
def decode_function(
|
||||
decoder: Any, code: bytes, start: int
|
||||
) -> list[Instruction]:
|
||||
end = start + len(code)
|
||||
instructions = []
|
||||
for address, size, mnemonic, operands in decoder.disasm_lite(code, start):
|
||||
if (mnemonic == "call" or mnemonic.startswith("j")) and operands.startswith("0x"):
|
||||
target = int(operands, 16)
|
||||
if mnemonic == "call":
|
||||
shape = "call"
|
||||
else:
|
||||
shape = mnemonic + (" in" if start <= target < end else " out")
|
||||
instructions.append(Instruction(address, shape, (), target))
|
||||
continue
|
||||
rip_targets = []
|
||||
for match in _RIP_OPERAND.finditer(operands):
|
||||
displacement = int(match.group(2), 0)
|
||||
rip_targets.append(
|
||||
address + size + (-displacement if match.group(1) == "-" else displacement)
|
||||
)
|
||||
operands = _IMMEDIATE.sub(_stable_immediate, _RIP_OPERAND.sub("[rip]", operands))
|
||||
instructions.append(
|
||||
Instruction(address, f"{mnemonic} {operands}", tuple(rip_targets), None)
|
||||
)
|
||||
return instructions
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class FunctionInfo:
|
||||
size: int
|
||||
shape_hash: bytes
|
||||
calls: tuple[int, ...]
|
||||
refs: tuple[int, ...]
|
||||
|
||||
|
||||
def function_table(image: Any) -> list[tuple[int, int]]:
|
||||
"""Returns (start, size) for every FDE indexed by `.eh_frame_hdr`."""
|
||||
header = image.sections.get(".eh_frame_hdr")
|
||||
if header is None:
|
||||
raise AnalyzerError("libroblox has no .eh_frame_hdr")
|
||||
raw = image.section_bytes(header)
|
||||
# Version 1, a 4-byte eh_frame_ptr, udata4 count, datarel sdata4 table.
|
||||
if len(raw) < 12 or raw[0] != 1 or raw[2] != 0x03 or raw[3] != 0x3B:
|
||||
raise AnalyzerError(".eh_frame_hdr uses an unsupported encoding")
|
||||
if raw[1] == 0xFF or raw[1] & 0x0F not in (0x03, 0x0B):
|
||||
raise AnalyzerError(".eh_frame_hdr eh_frame_ptr encoding is not 4 bytes")
|
||||
count = struct.unpack_from("<I", raw, 8)[0]
|
||||
if 12 + count * 8 > len(raw):
|
||||
raise AnalyzerError(".eh_frame_hdr table exceeds its section")
|
||||
table = []
|
||||
for index in range(count):
|
||||
location, fde = struct.unpack_from("<ii", raw, 12 + index * 8)
|
||||
start = header.address + location
|
||||
fde_rva = header.address + fde
|
||||
offset = image.rva_to_offset(fde_rva, 16)
|
||||
length, _, begin, size = struct.unpack_from("<IIiI", image.data, offset)
|
||||
# An FDE starts with its length, CIE pointer, then a pcrel sdata4
|
||||
# pc_begin and its udata4 range.
|
||||
if length == 0xFFFFFFFF or fde_rva + 8 + begin != start:
|
||||
raise AnalyzerError(".eh_frame FDE does not match its index entry")
|
||||
table.append((start, size))
|
||||
table.sort()
|
||||
return table
|
||||
|
||||
|
||||
_SOURCE_DIGEST = hashlib.sha256(Path(__file__).read_bytes()).hexdigest()[:16]
|
||||
|
||||
|
||||
def cache_path(cache_dir: Path, library_sha256: str) -> Path:
|
||||
"""Cache file for one library; shapes depend on this code and capstone."""
|
||||
version = getattr(DERIVER.capstone, "__version__", "unknown")
|
||||
return cache_dir / f"{library_sha256}-{_SOURCE_DIGEST}-capstone{version}.json.gz"
|
||||
|
||||
|
||||
def link_functions(
|
||||
functions: dict[int, FunctionInfo],
|
||||
) -> tuple[dict[int, list[int]], dict[int, list[int]]]:
|
||||
"""Returns each function's callers and each data address's users, once each."""
|
||||
callers: dict[int, list[int]] = collections.defaultdict(list)
|
||||
data_users: dict[int, list[int]] = collections.defaultdict(list)
|
||||
for start, info in functions.items():
|
||||
for target in dict.fromkeys(info.calls):
|
||||
if target in functions:
|
||||
callers[target].append(start)
|
||||
for target in dict.fromkeys(info.refs):
|
||||
data_users[target].append(start)
|
||||
return callers, data_users
|
||||
|
||||
|
||||
def _int_list(value: Any) -> tuple[int, ...]:
|
||||
if not isinstance(value, list) or not all(type(item) is int for item in value):
|
||||
raise ValueError("cached index entry is malformed")
|
||||
return tuple(value)
|
||||
|
||||
|
||||
def _read_cache(path: Path) -> dict[int, FunctionInfo] | None:
|
||||
"""Returns the cached functions, or None when the file is missing or bad."""
|
||||
try:
|
||||
with gzip.open(path, "rt", encoding="utf-8") as stream:
|
||||
entries = json.load(stream)
|
||||
if not isinstance(entries, list) or not entries:
|
||||
raise ValueError("cached index is empty")
|
||||
functions = {}
|
||||
for entry in entries:
|
||||
start, size, shape_hash, calls, refs = entry
|
||||
if type(start) is not int or type(size) is not int:
|
||||
raise ValueError("cached index entry is malformed")
|
||||
functions[start] = FunctionInfo(
|
||||
size, bytes.fromhex(shape_hash), _int_list(calls), _int_list(refs)
|
||||
)
|
||||
return functions
|
||||
except (OSError, EOFError, ValueError, TypeError):
|
||||
return None
|
||||
|
||||
|
||||
def _write_cache(path: Path, functions: dict[int, FunctionInfo]) -> None:
|
||||
# A cache that cannot be written only costs the next run a rebuild.
|
||||
entries = [
|
||||
[start, info.size, info.shape_hash.hex(), list(info.calls), list(info.refs)]
|
||||
for start, info in functions.items()
|
||||
]
|
||||
try:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
descriptor, temporary = tempfile.mkstemp(dir=path.parent, suffix=".tmp")
|
||||
except OSError:
|
||||
return
|
||||
try:
|
||||
with os.fdopen(descriptor, "wb") as raw, gzip.open(raw, "wt", encoding="utf-8") as stream:
|
||||
json.dump(entries, stream, separators=(",", ":"))
|
||||
os.replace(temporary, path)
|
||||
except OSError:
|
||||
Path(temporary).unlink(missing_ok=True)
|
||||
|
||||
|
||||
class FunctionIndex:
|
||||
"""Normalized shapes, calls and data references of every function.
|
||||
|
||||
With `cache_dir`, the per-function data is kept in a file named after the
|
||||
library's SHA-256, this module's source and the capstone version, and read
|
||||
back instead of decoding the library again.
|
||||
"""
|
||||
|
||||
def __init__(self, image: Any, cache_dir: Path | None = None):
|
||||
DERIVER.require_capstone()
|
||||
self.image = image
|
||||
self.decoder = DERIVER.capstone.Cs(
|
||||
DERIVER.capstone.CS_ARCH_X86, DERIVER.capstone.CS_MODE_64
|
||||
)
|
||||
self.text = image.sections[".text"]
|
||||
self._decoded: dict[int, list[Instruction]] = {}
|
||||
path = None if cache_dir is None else cache_path(Path(cache_dir), image.sha256)
|
||||
functions = None if path is None else _read_cache(path)
|
||||
if functions is None:
|
||||
functions = self._decode_all()
|
||||
if path is not None:
|
||||
_write_cache(path, functions)
|
||||
self.functions = functions
|
||||
self.starts = sorted(self.functions)
|
||||
self.callers, self.data_users = link_functions(self.functions)
|
||||
|
||||
def _decode_all(self) -> dict[int, FunctionInfo]:
|
||||
text_end = self.text.address + self.text.size
|
||||
functions = {}
|
||||
for start, size in function_table(self.image):
|
||||
if size == 0 or not self.text.address <= start < text_end:
|
||||
continue
|
||||
instructions = self.instructions(start, size, cache=False)
|
||||
shape_hash = hashlib.blake2b(
|
||||
"\n".join(item.shape for item in instructions).encode(), digest_size=8
|
||||
).digest()
|
||||
calls = tuple(
|
||||
item.branch_target
|
||||
for item in instructions
|
||||
if item.branch_target is not None
|
||||
and (item.shape == "call" or item.shape.endswith(" out"))
|
||||
)
|
||||
refs = tuple(target for item in instructions for target in item.rip_targets)
|
||||
functions[start] = FunctionInfo(size, shape_hash, calls, refs)
|
||||
return functions
|
||||
|
||||
def instructions(
|
||||
self, start: int, size: int | None = None, cache: bool = True
|
||||
) -> list[Instruction]:
|
||||
if cache and start in self._decoded:
|
||||
return self._decoded[start]
|
||||
if size is None:
|
||||
size = self.functions[start].size
|
||||
offset = self.text.offset + start - self.text.address
|
||||
decoded = decode_function(self.decoder, self.image.data[offset : offset + size], start)
|
||||
if cache:
|
||||
self._decoded[start] = decoded
|
||||
return decoded
|
||||
|
||||
def shapes(self, start: int) -> list[str]:
|
||||
# Scoring reads each candidate once; only aligned functions stay cached.
|
||||
return [item.shape for item in self.instructions(start, cache=start in self._decoded)]
|
||||
|
||||
def containing(self, rva: int) -> int | None:
|
||||
index = bisect.bisect_right(self.starts, rva) - 1
|
||||
if index < 0:
|
||||
return None
|
||||
start = self.starts[index]
|
||||
return start if rva < start + self.functions[start].size else None
|
||||
|
||||
def string_at(self, rva: int) -> bytes | None:
|
||||
segment = self.image.segment_for_rva(rva)
|
||||
if segment is None or not segment.contains_file_data(rva):
|
||||
return None
|
||||
offset = self.image.rva_to_offset(rva)
|
||||
raw = self.image.data[offset : offset + 96]
|
||||
end = raw.find(b"\0")
|
||||
if end < 4 or not all(32 <= byte < 127 for byte in raw[:end]):
|
||||
return None
|
||||
return raw[:end]
|
||||
@@ -6,8 +6,9 @@
|
||||
Usage: summarize_profile_trace.py TRACE [TRACE ...]
|
||||
|
||||
Each trace gets its own column, so `before.json after.json` compares them.
|
||||
Frame times come from the "frame interval (ms)" counter; every other row is
|
||||
a slice name recorded by the Vulkan adapter.
|
||||
Frame times come from the "frame interval (ms)" counter, peaks from the
|
||||
texture counters; every other row is a slice name recorded by the Vulkan
|
||||
adapter.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -20,6 +21,7 @@ import sys
|
||||
from typing import Iterable
|
||||
|
||||
FRAME_COUNTER = "frame interval (ms)"
|
||||
PEAK_COUNTERS = ("emulated texture (MB)", "compressed texture (MB)")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -37,6 +39,7 @@ class Distribution:
|
||||
class Summary:
|
||||
frames: Distribution | None
|
||||
slices: dict[str, Distribution]
|
||||
peaks: dict[str, float]
|
||||
|
||||
|
||||
def _nearest_rank(ordered: list[float], percent: float) -> float:
|
||||
@@ -57,16 +60,21 @@ def _distribution(values: list[float]) -> Distribution:
|
||||
def summarize(events: Iterable[dict]) -> Summary:
|
||||
frames: list[float] = []
|
||||
slices: dict[str, list[float]] = {}
|
||||
peaks: dict[str, float] = {}
|
||||
for event in events:
|
||||
phase = event.get("ph")
|
||||
if phase == "C" and event.get("name") == FRAME_COUNTER:
|
||||
frames.append(float(event["args"]["value"]))
|
||||
elif phase == "C" and event.get("name") in PEAK_COUNTERS:
|
||||
value = float(event["args"]["value"])
|
||||
peaks[event["name"]] = max(peaks.get(event["name"], value), value)
|
||||
elif phase == "X":
|
||||
slices.setdefault(event["name"], []).append(event["dur"] / 1000)
|
||||
return Summary(
|
||||
frames=_distribution(frames) if frames else None,
|
||||
slices={name: _distribution(values)
|
||||
for name, values in slices.items()})
|
||||
for name, values in slices.items()},
|
||||
peaks=peaks)
|
||||
|
||||
|
||||
def _row(label: str, cells: list[str]) -> str:
|
||||
@@ -96,6 +104,11 @@ def to_markdown(traces: list[tuple[str, Summary]]) -> str:
|
||||
if any(frames):
|
||||
lines += [_metric_row(f"frame interval {field} (ms)", frames, field)
|
||||
for field in ("mean", "p50", "p95", "p99", "max")]
|
||||
for name in PEAK_COUNTERS:
|
||||
if any(name in summary.peaks for summary in summaries):
|
||||
lines.append(_row(f"{name} peak", [
|
||||
f"{summary.peaks[name]:.2f}" if name in summary.peaks else "-"
|
||||
for summary in summaries]))
|
||||
|
||||
# Largest total time first, taken from whichever trace spent the most.
|
||||
totals: dict[str, float] = {}
|
||||
|
||||
@@ -28,6 +28,7 @@ STORE_ROOT=""
|
||||
TEMP_DIR=""
|
||||
ROLLBACK_DIR=""
|
||||
ROLLBACK_NEEDED=false
|
||||
BACKUP_COMPLETE=false
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
@@ -146,34 +147,54 @@ certificate_digests() {
|
||||
}
|
||||
|
||||
restore_payload() {
|
||||
[[ "${ROLLBACK_NEEDED}" == true && -d "${ROLLBACK_DIR}" ]] || return 0
|
||||
[[ "${ROLLBACK_NEEDED}" == true ]] || return 0
|
||||
[[ -d "${ROLLBACK_DIR}" ]] || return 1
|
||||
|
||||
log WARN "restoring the previous payload"
|
||||
mkdir -p "${RBX_BIN_DIR}" "$(dirname -- "${METADATA_PATH}")"
|
||||
mkdir -p "${RBX_BIN_DIR}" "$(dirname -- "${METADATA_PATH}")" || return 1
|
||||
|
||||
local path
|
||||
for path in libroblox.so sober_apk assets; do
|
||||
if [[ -e "${RBX_BIN_DIR}/${path}" ]]; then
|
||||
mv -- "${RBX_BIN_DIR}/${path}" "${TEMP_DIR}/failed-${path}"
|
||||
local path active_path failed_path restore_status=0
|
||||
for path in libroblox.so sober_apk assets roblox_payload.json; do
|
||||
active_path="${RBX_BIN_DIR}/${path}"
|
||||
failed_path="${TEMP_DIR}/failed-${path}"
|
||||
if [[ "${path}" == roblox_payload.json ]]; then
|
||||
active_path="${METADATA_PATH}"
|
||||
failed_path="${TEMP_DIR}/failed-metadata.json"
|
||||
fi
|
||||
if [[ -e "${ROLLBACK_DIR}/${path}" ]]; then
|
||||
mv -- "${ROLLBACK_DIR}/${path}" "${RBX_BIN_DIR}/${path}"
|
||||
|
||||
# Before activation, anything still active belongs to the old payload.
|
||||
# Only components removed by the backup need restoring in this phase.
|
||||
if [[ "${BACKUP_COMPLETE}" == false ]]; then
|
||||
if [[ -e "${active_path}" || -L "${active_path}" ||
|
||||
! -e "${ROLLBACK_DIR}/${path}" && ! -L "${ROLLBACK_DIR}/${path}" ]]; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -e "${active_path}" || -L "${active_path}" ]]; then
|
||||
# Do not restore onto an occupied destination if removing the new
|
||||
# component fails: mv could overwrite a file or nest a directory.
|
||||
if ! mv -- "${active_path}" "${failed_path}"; then
|
||||
restore_status=1
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
if [[ -e "${ROLLBACK_DIR}/${path}" || -L "${ROLLBACK_DIR}/${path}" ]]; then
|
||||
mv -- "${ROLLBACK_DIR}/${path}" "${active_path}" || restore_status=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -e "${METADATA_PATH}" ]]; then
|
||||
mv -- "${METADATA_PATH}" "${TEMP_DIR}/failed-metadata.json"
|
||||
fi
|
||||
if [[ -e "${ROLLBACK_DIR}/roblox_payload.json" ]]; then
|
||||
mv -- "${ROLLBACK_DIR}/roblox_payload.json" "${METADATA_PATH}"
|
||||
fi
|
||||
return "${restore_status}"
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
local -r status=$?
|
||||
local status=$?
|
||||
trap - EXIT
|
||||
set +e
|
||||
restore_payload
|
||||
if ! restore_payload; then
|
||||
log ERROR "payload restoration failed; recovery files retained at ${TEMP_DIR}"
|
||||
(( status != 0 )) || status=1
|
||||
exit "${status}"
|
||||
fi
|
||||
if [[ -n "${TEMP_DIR}" && -d "${TEMP_DIR}" ]]; then
|
||||
rm -rf -- "${TEMP_DIR}"
|
||||
fi
|
||||
@@ -401,17 +422,18 @@ main() {
|
||||
mkdir -p "${VERSIONS_DIR}" "$(dirname -- "${METADATA_PATH}")"
|
||||
ROLLBACK_DIR="${TEMP_DIR}/rollback"
|
||||
mkdir -p "${ROLLBACK_DIR}"
|
||||
ROLLBACK_NEEDED=true
|
||||
|
||||
local active_path
|
||||
for active_path in libroblox.so sober_apk assets; do
|
||||
if [[ -e "${RBX_BIN_DIR}/${active_path}" ]]; then
|
||||
if [[ -e "${RBX_BIN_DIR}/${active_path}" || -L "${RBX_BIN_DIR}/${active_path}" ]]; then
|
||||
mv -- "${RBX_BIN_DIR}/${active_path}" "${ROLLBACK_DIR}/${active_path}"
|
||||
fi
|
||||
done
|
||||
if [[ -e "${METADATA_PATH}" ]]; then
|
||||
if [[ -e "${METADATA_PATH}" || -L "${METADATA_PATH}" ]]; then
|
||||
mv -- "${METADATA_PATH}" "${ROLLBACK_DIR}/roblox_payload.json"
|
||||
fi
|
||||
ROLLBACK_NEEDED=true
|
||||
BACKUP_COMPLETE=true
|
||||
|
||||
mv -- "${stage_dir}/libroblox.so" "${RBX_BIN_DIR}/libroblox.so"
|
||||
mv -- "${stage_dir}/sober_apk" "${RBX_BIN_DIR}/sober_apk"
|
||||
|
||||
@@ -110,8 +110,14 @@ for elf in "$@"; do
|
||||
fi
|
||||
machine="$(LC_ALL=C readelf --file-header "${elf}" 2>/dev/null |
|
||||
sed -n 's/^[[:space:]]*Machine:[[:space:]]*//p')"
|
||||
if [[ "${machine}" != *X86-64* ]]; then
|
||||
printf 'ABI check: %s is not x86-64 (%s)\n' "${elf}" "${machine}" >&2
|
||||
case "$(uname -m)" in
|
||||
x86_64) expected_machine='X86-64' ;;
|
||||
aarch64) expected_machine='AArch64' ;;
|
||||
*) expected_machine='X86-64' ;;
|
||||
esac
|
||||
if [[ "${machine}" != *"${expected_machine}"* ]]; then
|
||||
printf 'ABI check: %s is not %s (%s)\n' "${elf}" "${expected_machine}" \
|
||||
"${machine}" >&2
|
||||
status=1
|
||||
fi
|
||||
|
||||
|
||||
+124
-39
@@ -5,47 +5,132 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="dark">
|
||||
<title>Nightcap for Linux</title>
|
||||
<title>Nightcap: Roblox on Linux</title>
|
||||
<meta name="description" content="Roblox on Linux, tuned for desktop play. A Mocktail fork that keeps up with Roblox updates, with extra bug fixes, custom assets and more.">
|
||||
<meta name="google-site-verification" content="vznL8W2txRlmfwhGg7ZBPSxQaPV9OtaIUoYPvmd9aUA">
|
||||
<link rel="canonical" href="https://coderdayton.github.io/nightcap/">
|
||||
<link rel="icon" href="nightcap.svg" type="image/svg+xml">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:site_name" content="Nightcap">
|
||||
<meta property="og:title" content="Nightcap: Roblox on Linux">
|
||||
<meta property="og:description" content="Roblox on Linux, tuned for desktop play. A Mocktail fork that keeps up with Roblox updates, with extra bug fixes, custom assets and more.">
|
||||
<meta property="og:url" content="https://coderdayton.github.io/nightcap/">
|
||||
<meta property="og:image" content="https://coderdayton.github.io/nightcap/preview.png">
|
||||
<meta property="og:image:alt" content="Roblox running on Linux with Nightcap">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "SoftwareApplication",
|
||||
"name": "Nightcap",
|
||||
"description": "Roblox on Linux, tuned for desktop play. A Mocktail fork that keeps up with Roblox updates, with extra bug fixes, custom assets and more.",
|
||||
"applicationCategory": "GameApplication",
|
||||
"operatingSystem": "Linux",
|
||||
"url": "https://coderdayton.github.io/nightcap/",
|
||||
"downloadUrl": "https://github.com/CoderDayton/nightcap/releases/latest",
|
||||
"license": "https://www.apache.org/licenses/LICENSE-2.0",
|
||||
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" }
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
<body><main>
|
||||
<img src="nightcap.svg" alt="Nightcap logo">
|
||||
<h1>Nightcap</h1>
|
||||
<p>Play Roblox on Linux like it was made for your PC. Nightcap is Mocktail, tuned to feel fast and look sharp.</p>
|
||||
<a class="button" href="https://github.com/CoderDayton/nightcap/releases/latest/download/Nightcap-x86_64.AppImage">Download AppImage</a>
|
||||
<a class="button secondary" href="nightcap.flatpakref">Install with Flatpak</a>
|
||||
<div class="commands">
|
||||
<p>AppImage</p>
|
||||
<code>chmod +x Nightcap-x86_64.AppImage
|
||||
./Nightcap-x86_64.AppImage</code>
|
||||
<p>Flatpak</p>
|
||||
<code>flatpak install --user https://coderdayton.github.io/nightcap/nightcap.flatpakref
|
||||
flatpak run io.github.CoderDayton.nightcap</code>
|
||||
<p>Build from source</p>
|
||||
<code>git clone --recurse-submodules https://github.com/CoderDayton/nightcap.git
|
||||
<body>
|
||||
<header class="hero">
|
||||
<div class="wrap">
|
||||
<p class="top">
|
||||
<a href="https://github.com/CoderDayton/nightcap" aria-label="Nightcap on GitHub" title="GitHub"><svg viewBox="0 0 16 16" width="24" height="24" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg></a>
|
||||
<a href="https://discord.gg/DbAUG9hBFU" aria-label="Nightcap on Discord" title="Discord"><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="currentColor" d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"/></svg></a>
|
||||
</p>
|
||||
<p class="eyebrow">Roblox on Linux, tuned for desktop play</p>
|
||||
<h1><img src="nightcap.svg" alt=""><span>Nightcap</span></h1>
|
||||
<p class="lede">A Mocktail fork that keeps up with Roblox updates, with extra bug fixes, custom assets and more.</p>
|
||||
<p class="actions">
|
||||
<a class="button" href="https://github.com/CoderDayton/nightcap/releases/latest/download/Nightcap-x86_64.AppImage">Download AppImage</a>
|
||||
<a class="button secondary" href="nightcap.flatpakref">Install with Flatpak</a>
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="wrap">
|
||||
<section class="row stacked">
|
||||
<h2>Install</h2>
|
||||
<dl class="body install">
|
||||
<dt>AppImage</dt>
|
||||
<dd><pre><code>chmod +x Nightcap-x86_64.AppImage
|
||||
./Nightcap-x86_64.AppImage</code></pre></dd>
|
||||
<dt>Flatpak</dt>
|
||||
<dd><pre><code>flatpak install --user https://coderdayton.github.io/nightcap/nightcap.flatpakref
|
||||
flatpak run io.github.CoderDayton.nightcap</code></pre></dd>
|
||||
<dt>DEB, RPM, pacman</dt>
|
||||
<dd><pre><code>sudo apt install ./nightcap_<version>-1_amd64.deb
|
||||
sudo dnf install ./nightcap-<version>-1.x86_64.rpm
|
||||
sudo pacman -U nightcap-<version>-1-x86_64.pkg.tar.zst</code></pre></dd>
|
||||
<dt>Source</dt>
|
||||
<dd><pre><code>git clone --recurse-submodules https://github.com/CoderDayton/nightcap.git
|
||||
cd nightcap && make build
|
||||
./build/mocktail</code>
|
||||
</div>
|
||||
<h2>What's different</h2>
|
||||
<ul>
|
||||
<li>Lower input lag. Frames are shown as soon as they are ready.</li>
|
||||
<li>Sharper textures, with your own PNG overrides if you want them.</li>
|
||||
<li>ETC2 textures render correctly on desktop GPUs.</li>
|
||||
<li>No more error 319 kicks after joining a server.</li>
|
||||
<li>Roblox sees your real RAM and screen size.</li>
|
||||
</ul>
|
||||
<h2>Direct downloads</h2>
|
||||
<p>Prebuilt builds for Linux x86_64.</p>
|
||||
<p class="links">
|
||||
<a href="https://github.com/CoderDayton/nightcap/releases/latest/download/Nightcap-x86_64.AppImage">AppImage</a>
|
||||
<a href="Nightcap-x86_64.flatpak">Flatpak bundle</a>
|
||||
<a href="nightcap-flatpak.gpg">Signing key</a>
|
||||
<a href="terms.html">Terms</a>
|
||||
<a href="privacy.html">Privacy</a>
|
||||
</p>
|
||||
<p><a class="source" href="https://github.com/CoderDayton/nightcap">Source code</a> ·
|
||||
<a class="source" href="https://github.com/komaruworld/mocktail">Upstream Mocktail</a></p>
|
||||
<p>Nightcap is an independent community project and is not affiliated with Roblox Corporation.</p>
|
||||
</main></body>
|
||||
./build/mocktail</code></pre></dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section class="row">
|
||||
<h2>What's different</h2>
|
||||
<dl class="body facts">
|
||||
<dt>Roblox updates</dt>
|
||||
<dd>New Roblox versions work soon after they come out.</dd>
|
||||
<dt>More games</dt>
|
||||
<dd>Answers a server check some experiences use, so you can play those too.</dd>
|
||||
<dt>Voice chat</dt>
|
||||
<dd>Your microphone still works after a Roblox update.</dd>
|
||||
<dt>Login</dt>
|
||||
<dd>Verification checks and captchas finish instead of hanging.</dd>
|
||||
<dt>Look</dt>
|
||||
<dd>The new home screen and side menu, like on Windows.</dd>
|
||||
<dt>Your own assets</dt>
|
||||
<dd>Drop in your own cursors, fonts and skies. The folder layout matches Sober's.</dd>
|
||||
<dt>Mouse and CPU</dt>
|
||||
<dd>Optional raw mouse input, and less CPU use while idle.</dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section class="row">
|
||||
<h2>Direct downloads</h2>
|
||||
<div class="body">
|
||||
<p>Prebuilt builds for Linux x86_64.</p>
|
||||
<ul class="links">
|
||||
<li><a href="https://github.com/CoderDayton/nightcap/releases/latest/download/Nightcap-x86_64.AppImage"><span class="name">AppImage</span><span class="file">Nightcap-x86_64.AppImage</span><span class="go" aria-hidden="true">↓</span></a></li>
|
||||
<li><a href="Nightcap-x86_64.flatpak"><span class="name">Flatpak bundle</span><span class="file">Nightcap-x86_64.flatpak</span><span class="go" aria-hidden="true">↓</span></a></li>
|
||||
<li><a href="https://github.com/CoderDayton/nightcap/releases/latest"><span class="name">DEB, RPM, pacman</span><span class="file">GitHub releases page</span><span class="go" aria-hidden="true">↗</span></a></li>
|
||||
<li><a href="nightcap-flatpak.gpg"><span class="name">Signing key</span><span class="file">nightcap-flatpak.gpg</span><span class="go" aria-hidden="true">↓</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="wrap foot">
|
||||
<p>
|
||||
<a href="https://github.com/CoderDayton/nightcap">Source code</a> ·
|
||||
<a href="https://github.com/komaruworld/mocktail">Upstream Mocktail</a> ·
|
||||
<a href="terms.html">Terms</a> ·
|
||||
<a href="privacy.html">Privacy</a>
|
||||
</p>
|
||||
<p>Nightcap is an independent community project and is not affiliated with Roblox Corporation.</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
// Adds a copy button to each command block. The page works without it.
|
||||
document.querySelectorAll('.install dd').forEach(function (block) {
|
||||
var button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.textContent = 'copy';
|
||||
button.addEventListener('click', function () {
|
||||
if (!navigator.clipboard) return;
|
||||
navigator.clipboard.writeText(block.querySelector('code').textContent).then(function () {
|
||||
button.textContent = 'copied';
|
||||
setTimeout(function () { button.textContent = 'copy'; }, 1600);
|
||||
});
|
||||
});
|
||||
block.appendChild(button);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 419 KiB |
+36
-26
@@ -8,36 +8,46 @@
|
||||
<link rel="icon" href="nightcap.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
<body><main>
|
||||
<h1>Privacy Policy</h1>
|
||||
<p>Nightcap is a Linux runtime for the Roblox Android client. This policy covers Nightcap itself and its Discord application. Roblox and Discord have their own policies for the data they handle.</p>
|
||||
<body>
|
||||
<header class="wrap bar">
|
||||
<a class="brand" href="index.html"><img src="nightcap.svg" alt="" width="30" height="30"><span>Nightcap</span></a>
|
||||
<p class="top">
|
||||
<a href="https://github.com/CoderDayton/nightcap" aria-label="Nightcap on GitHub" title="GitHub"><svg viewBox="0 0 16 16" width="24" height="24" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg></a>
|
||||
<a href="https://discord.gg/DbAUG9hBFU" aria-label="Nightcap on Discord" title="Discord"><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="currentColor" d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"/></svg></a>
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<h2>What Nightcap collects</h2>
|
||||
<p>Nothing. Nightcap has no server. It does not collect, store, or send telemetry, analytics, crash reports, or account data to the Nightcap project.</p>
|
||||
<main class="wrap prose">
|
||||
<h1>Privacy Policy</h1>
|
||||
<p>Nightcap is a Linux runtime for the Roblox Android client. This policy covers Nightcap itself and its Discord application. Roblox and Discord have their own policies for the data they handle.</p>
|
||||
|
||||
<h2>What stays on your machine</h2>
|
||||
<ul>
|
||||
<li>Configuration in <code>~/.config/mocktail/</code></li>
|
||||
<li>Session logs and support bundles in <code>~/.local/state/mocktail/</code></li>
|
||||
<li>Roblox login session under <code>~/.local/share/mocktail/</code></li>
|
||||
<li>Roblox cache, downloaded payloads, and shader cache under <code>~/.cache/mocktail/</code></li>
|
||||
</ul>
|
||||
<p>Flatpak installs keep the same layout under <code>~/.var/app/io.github.CoderDayton.nightcap/</code>.</p>
|
||||
<h2>What Nightcap collects</h2>
|
||||
<p>Nothing. Nightcap has no server. It does not collect, store, or send telemetry, analytics, crash reports, or account data to the Nightcap project.</p>
|
||||
|
||||
<h2>Discord Rich Presence</h2>
|
||||
<p>When Rich Presence is on, Nightcap sends the current experience name, its public icon URL, elapsed time, and an optional public server join code to the Discord desktop client on the same machine over a local socket. Discord displays this on your profile under its own privacy settings. Nightcap never signs in to Discord, never reads a Discord token, and never contacts Discord's servers.</p>
|
||||
<p>Set <code>integrations.discord_rpc.enabled: false</code> in <code>config.yaml</code> to turn it off.</p>
|
||||
<h2>What stays on your machine</h2>
|
||||
<ul>
|
||||
<li>Configuration in <code>~/.config/mocktail/</code></li>
|
||||
<li>Session logs and support bundles in <code>~/.local/state/mocktail/</code></li>
|
||||
<li>Roblox login session under <code>~/.local/share/mocktail/</code></li>
|
||||
<li>Roblox cache, downloaded payloads, and shader cache under <code>~/.cache/mocktail/</code></li>
|
||||
</ul>
|
||||
<p>Flatpak installs keep the same layout under <code>~/.var/app/io.github.CoderDayton.nightcap/</code>.</p>
|
||||
|
||||
<h2>Roblox</h2>
|
||||
<p>Nightcap talks to Roblox's services exactly as the Roblox client would. That traffic is covered by the Roblox Privacy Policy.</p>
|
||||
<h2>Discord Rich Presence</h2>
|
||||
<p>When Rich Presence is on, Nightcap sends the current experience name, its public icon URL, elapsed time, and an optional public server join code to the Discord desktop client on the same machine over a local socket. Discord displays this on your profile under its own privacy settings. Nightcap never signs in to Discord, never reads a Discord token, and never contacts Discord's servers.</p>
|
||||
<p>Set <code>integrations.discord_rpc.enabled: false</code> in <code>config.yaml</code> to turn it off.</p>
|
||||
|
||||
<h2>Contact</h2>
|
||||
<p>Open an issue at <a class="source" href="https://github.com/CoderDayton/nightcap/issues">github.com/CoderDayton/nightcap/issues</a>.</p>
|
||||
<h2>Roblox</h2>
|
||||
<p>Nightcap talks to Roblox's services exactly as the Roblox client would. That traffic is covered by the Roblox Privacy Policy.</p>
|
||||
|
||||
<p class="links">
|
||||
<a href="index.html">Home</a>
|
||||
<a href="terms.html">Terms of Service</a>
|
||||
<a href="https://github.com/CoderDayton/nightcap">Source code</a>
|
||||
</p>
|
||||
</main></body>
|
||||
<h2>Contact</h2>
|
||||
<p>Open an issue at <a href="https://github.com/CoderDayton/nightcap/issues">github.com/CoderDayton/nightcap/issues</a>.</p>
|
||||
|
||||
<p class="legal-nav">
|
||||
<a href="index.html">Home</a>
|
||||
<a href="terms.html">Terms of Service</a>
|
||||
<a href="https://github.com/CoderDayton/nightcap">Source code</a>
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
+260
-49
@@ -1,94 +1,305 @@
|
||||
/* Modified by vii from komaruworld/mocktail. See README "About this fork". */
|
||||
:root {
|
||||
font: 17px/1.55 system-ui, sans-serif;
|
||||
--bg: #14122b;
|
||||
--ink: #ece8ff;
|
||||
--muted: #b3aad6;
|
||||
--accent: #6c4fd1;
|
||||
--link: #a78bfa;
|
||||
--line: #3a3470;
|
||||
--code-bg: #1d1a3d;
|
||||
font: 17px/1.6 system-ui, sans-serif;
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #14122b;
|
||||
color: #ece8ff;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 680px;
|
||||
margin: 12vh auto;
|
||||
padding: 32px;
|
||||
a { color: var(--link); }
|
||||
a:focus-visible,
|
||||
button:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
|
||||
|
||||
.wrap {
|
||||
position: relative;
|
||||
max-width: 920px;
|
||||
margin: 0 auto;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
.hero { padding-bottom: clamp(48px, 10vh, 110px); }
|
||||
|
||||
.top {
|
||||
margin: 0;
|
||||
padding-top: 22px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: .2rem 0;
|
||||
font-size: clamp(2.5rem, 8vw, 4.5rem);
|
||||
.top a {
|
||||
display: block;
|
||||
color: var(--muted);
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 32px 0 0;
|
||||
font-size: 1.15rem;
|
||||
.top a:hover { color: var(--ink); }
|
||||
|
||||
.eyebrow {
|
||||
display: inline-block;
|
||||
margin: clamp(48px, 12vh, 130px) 0 0;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--code-bg);
|
||||
color: var(--link);
|
||||
font-size: .85rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: .06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
p,
|
||||
li {
|
||||
color: #b3aad6;
|
||||
.hero h1 {
|
||||
margin: 18px 0 0;
|
||||
font-size: clamp(3.6rem, 15vw, 9.5rem);
|
||||
font-weight: 800;
|
||||
line-height: .95;
|
||||
letter-spacing: -.045em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: .16em;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 1.2rem;
|
||||
.hero h1 img {
|
||||
height: .78em;
|
||||
width: auto;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.lede {
|
||||
max-width: 34ch;
|
||||
margin: 22px 0 0;
|
||||
color: var(--ink);
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.actions { margin: 28px 0 0; }
|
||||
|
||||
a.button {
|
||||
display: inline-block;
|
||||
margin: 16px 8px 16px 0;
|
||||
padding: 12px 18px;
|
||||
border-radius: 9px;
|
||||
background: #6c4fd1;
|
||||
color: white;
|
||||
margin: 0 10px 10px 0;
|
||||
padding: 12px 20px;
|
||||
border: 2px solid var(--accent);
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.secondary {
|
||||
background: #2f2a6b;
|
||||
a.button:hover { background: #7d62dd; border-color: #7d62dd; }
|
||||
|
||||
a.button.secondary {
|
||||
background: var(--bg);
|
||||
border-color: var(--link);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.commands {
|
||||
margin-top: 10px;
|
||||
a.button.secondary:hover { background: var(--code-bg); }
|
||||
|
||||
/* Every section is a label on the left and its content on the right. */
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 200px 1fr;
|
||||
gap: 8px 32px;
|
||||
padding: 36px 0;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.commands p,
|
||||
.download-label {
|
||||
margin: 14px 0 5px;
|
||||
color: #ece8ff;
|
||||
font-size: .82rem;
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: .04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.row.stacked { grid-template-columns: 1fr; gap: 20px; }
|
||||
|
||||
.body { margin: 0; min-width: 0; }
|
||||
.body p { margin: 0 0 12px; color: var(--muted); }
|
||||
|
||||
dl.body {
|
||||
display: grid;
|
||||
grid-template-columns: max-content 1fr;
|
||||
gap: 0 28px;
|
||||
}
|
||||
|
||||
dt {
|
||||
padding: 9px 0;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
dd {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding: 9px 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.facts dt,
|
||||
.facts dd { border-bottom: 1px solid var(--line); }
|
||||
.facts dt:last-of-type,
|
||||
.facts dd:last-of-type { border-bottom: 0; }
|
||||
.facts dt { color: var(--ink); font-weight: 700; }
|
||||
|
||||
dl.body.install { display: block; }
|
||||
|
||||
.install dt {
|
||||
padding: 18px 0 6px;
|
||||
font-size: .9rem;
|
||||
}
|
||||
|
||||
.install dt:first-child { padding-top: 0; }
|
||||
.install dd { padding: 0; }
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
padding: 14px;
|
||||
overflow-x: auto;
|
||||
border-left: 3px solid var(--accent);
|
||||
background: var(--code-bg);
|
||||
}
|
||||
|
||||
code {
|
||||
display: block;
|
||||
padding: 14px;
|
||||
overflow-wrap: anywhere;
|
||||
border: 1px solid #3a3470;
|
||||
border-radius: 6px;
|
||||
background: #1d1a3d;
|
||||
font: .9rem/1.7 ui-monospace, "DejaVu Sans Mono", "JetBrains Mono", monospace;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
dd button {
|
||||
position: absolute;
|
||||
top: -30px;
|
||||
right: 0;
|
||||
padding: 2px 0 2px 8px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
font: .8rem ui-monospace, monospace;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
dd button:hover { color: var(--ink); text-decoration: underline; }
|
||||
|
||||
.links {
|
||||
margin: 10px 0 14px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.links li { border-bottom: 1px solid var(--line); }
|
||||
|
||||
.links a {
|
||||
display: inline-block;
|
||||
margin: 0 14px 6px 0;
|
||||
color: #a78bfa;
|
||||
display: grid;
|
||||
grid-template-columns: 200px 1fr 24px;
|
||||
align-items: baseline;
|
||||
gap: 4px 16px;
|
||||
margin: 0 -8px;
|
||||
padding: 12px 24px 12px 8px;
|
||||
color: var(--ink);
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.source {
|
||||
color: #a78bfa;
|
||||
.links a:hover { background: var(--code-bg); }
|
||||
.links a:hover .name { text-decoration: underline; text-decoration-color: var(--link); text-underline-offset: 4px; }
|
||||
|
||||
.links .file {
|
||||
color: var(--muted);
|
||||
font: 400 .88rem ui-monospace, "DejaVu Sans Mono", monospace;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.links .go { color: var(--link); text-align: right; }
|
||||
|
||||
.foot {
|
||||
padding-bottom: 48px;
|
||||
color: var(--muted);
|
||||
font-size: .9rem;
|
||||
}
|
||||
|
||||
.foot::before {
|
||||
content: "";
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.foot p { margin: 0 0 8px; }
|
||||
|
||||
/* Terms and privacy pages: a header bar and one readable column. */
|
||||
.bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-top: 22px;
|
||||
}
|
||||
|
||||
.bar .top { padding-top: 0; }
|
||||
|
||||
.brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--ink);
|
||||
font-size: 1.15rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -.02em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.brand img { width: 30px; height: 30px; }
|
||||
|
||||
.prose {
|
||||
padding-top: clamp(32px, 8vh, 80px);
|
||||
padding-bottom: 48px;
|
||||
}
|
||||
|
||||
.prose > * { max-width: 700px; }
|
||||
|
||||
.prose h1 {
|
||||
margin: 0 0 16px;
|
||||
font-size: clamp(2rem, 6vw, 3rem);
|
||||
line-height: 1.1;
|
||||
letter-spacing: -.03em;
|
||||
}
|
||||
|
||||
.prose h2 {
|
||||
margin: 36px 0 6px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid var(--line);
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.prose p,
|
||||
.prose li { margin: 0 0 12px; }
|
||||
.prose ul { margin: 0 0 12px; padding-left: 1.2rem; }
|
||||
|
||||
.prose code {
|
||||
padding: 1px 6px;
|
||||
background: var(--code-bg);
|
||||
font-size: .85rem;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.legal-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 28px; }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.row { grid-template-columns: 1fr; padding: 28px 0; }
|
||||
dl.body:not(.install) { grid-template-columns: 1fr; }
|
||||
.facts dt { padding-bottom: 0; border-bottom: 0; }
|
||||
.links a { grid-template-columns: 1fr 24px; }
|
||||
.links .file { grid-column: 1; grid-row: 2; }
|
||||
.links .go { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
|
||||
}
|
||||
+29
-19
@@ -8,29 +8,39 @@
|
||||
<link rel="icon" href="nightcap.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
<body><main>
|
||||
<h1>Terms of Service</h1>
|
||||
<p>Nightcap is free and open-source software licensed under the Apache License, Version 2.0. The license text shipped with the source governs your use of the software.</p>
|
||||
<body>
|
||||
<header class="wrap bar">
|
||||
<a class="brand" href="index.html"><img src="nightcap.svg" alt="" width="30" height="30"><span>Nightcap</span></a>
|
||||
<p class="top">
|
||||
<a href="https://github.com/CoderDayton/nightcap" aria-label="Nightcap on GitHub" title="GitHub"><svg viewBox="0 0 16 16" width="24" height="24" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg></a>
|
||||
<a href="https://discord.gg/DbAUG9hBFU" aria-label="Nightcap on Discord" title="Discord"><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="currentColor" d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"/></svg></a>
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<h2>No warranty</h2>
|
||||
<p>Nightcap is provided "as is", without warranty of any kind. The authors are not liable for any loss, damage, or account action that results from using it. See sections 7 and 8 of the Apache License.</p>
|
||||
<main class="wrap prose">
|
||||
<h1>Terms of Service</h1>
|
||||
<p>Nightcap is free and open-source software licensed under the Apache License, Version 2.0. The license text shipped with the source governs your use of the software.</p>
|
||||
|
||||
<h2>Not affiliated</h2>
|
||||
<p>Nightcap is an independent community project. It is not affiliated with, endorsed by, or supported by Roblox Corporation or Discord Inc. Roblox and Discord are trademarks of their respective owners.</p>
|
||||
<h2>No warranty</h2>
|
||||
<p>Nightcap is provided "as is", without warranty of any kind. The authors are not liable for any loss, damage, or account action that results from using it. See sections 7 and 8 of the Apache License.</p>
|
||||
|
||||
<h2>Your responsibility</h2>
|
||||
<p>You are responsible for following the Roblox Terms of Use and the Discord Terms of Service while using Nightcap with those services. Nightcap does not modify Roblox game logic, does not bypass Roblox security, and is not a cheat.</p>
|
||||
<h2>Not affiliated</h2>
|
||||
<p>Nightcap is an independent community project. It is not affiliated with, endorsed by, or supported by Roblox Corporation or Discord Inc. Roblox and Discord are trademarks of their respective owners.</p>
|
||||
|
||||
<h2>Discord application</h2>
|
||||
<p>The Nightcap Discord application only provides Rich Presence for the Nightcap desktop runtime. It requests no permissions, has no bot, and does not access your Discord account.</p>
|
||||
<h2>Your responsibility</h2>
|
||||
<p>You are responsible for following the Roblox Terms of Use and the Discord Terms of Service while using Nightcap with those services. Nightcap does not modify Roblox game logic, does not bypass Roblox security, and is not a cheat.</p>
|
||||
|
||||
<h2>Changes</h2>
|
||||
<p>These terms may change with new releases. The current version always lives at this address.</p>
|
||||
<h2>Discord application</h2>
|
||||
<p>The Nightcap Discord application only provides Rich Presence for the Nightcap desktop runtime. It requests no permissions, has no bot, and does not access your Discord account.</p>
|
||||
|
||||
<p class="links">
|
||||
<a href="index.html">Home</a>
|
||||
<a href="privacy.html">Privacy Policy</a>
|
||||
<a href="https://github.com/CoderDayton/nightcap">Source code</a>
|
||||
</p>
|
||||
</main></body>
|
||||
<h2>Changes</h2>
|
||||
<p>These terms may change with new releases. The current version always lives at this address.</p>
|
||||
|
||||
<p class="legal-nav">
|
||||
<a href="index.html">Home</a>
|
||||
<a href="privacy.html">Privacy Policy</a>
|
||||
<a href="https://github.com/CoderDayton/nightcap">Source code</a>
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -31,18 +32,18 @@ struct NativeOptionalFormat {
|
||||
struct NativeSharedSink { void* object; void* owner; };
|
||||
static_assert(sizeof(NativeOptionalFormat) == 16);
|
||||
static_assert(sizeof(NativePcmFormat) == 8);
|
||||
inline std::atomic<NativeInputCapture*> g_native_capture{nullptr};
|
||||
inline std::shared_ptr<NativeInputCapture> g_native_capture;
|
||||
|
||||
class NativeInputCapture {
|
||||
public:
|
||||
using DeliverPcm = std::size_t (*)(void*, const void*, std::size_t,
|
||||
std::uint64_t, const NativePcmFormat*);
|
||||
using Destroy = void (*)(NativeSharedSink*);
|
||||
using OriginalLatency = void (*)(void*, std::uint32_t*, std::uint32_t*);
|
||||
using ImageRange = bool (*)(std::uintptr_t, std::uintptr_t, std::size_t);
|
||||
struct SinkAbi {
|
||||
std::uintptr_t vtable;
|
||||
DeliverPcm deliver;
|
||||
Destroy release;
|
||||
std::uintptr_t image_base;
|
||||
ImageRange is_image_relro;
|
||||
ImageRange is_image_code;
|
||||
OriginalLatency latency;
|
||||
};
|
||||
NativeInputCapture(SinkAbi abi, bool enabled)
|
||||
@@ -50,17 +51,22 @@ class NativeInputCapture {
|
||||
~NativeInputCapture() { Shutdown(); }
|
||||
|
||||
static NativeOptionalFormat Format(void*) {
|
||||
auto* capture = g_native_capture.load(std::memory_order_acquire);
|
||||
return {{}, capture && capture->enabled_ ? 1ULL : 0ULL};
|
||||
auto capture =
|
||||
std::atomic_load_explicit(&g_native_capture, std::memory_order_acquire);
|
||||
if (!capture) return {};
|
||||
std::lock_guard lock(capture->mutex_);
|
||||
return {{}, capture->enabled_ && !capture->closed_ ? 1ULL : 0ULL};
|
||||
}
|
||||
static void Latency(void* self, std::uint32_t* playback,
|
||||
std::uint32_t* recording) {
|
||||
// Preserve the native playback latency and report the host capture queue.
|
||||
auto* capture = g_native_capture.load(std::memory_order_acquire);
|
||||
auto capture =
|
||||
std::atomic_load_explicit(&g_native_capture, std::memory_order_acquire);
|
||||
if (!capture) return;
|
||||
std::lock_guard lock(capture->mutex_);
|
||||
if (capture->closed_) return;
|
||||
capture->abi_.latency(self, playback, recording);
|
||||
if (recording) {
|
||||
std::lock_guard lock(capture->mutex_);
|
||||
*recording = 10;
|
||||
auto it = capture->sessions_.find(self);
|
||||
if (it != capture->sessions_.end()) {
|
||||
@@ -70,33 +76,48 @@ class NativeInputCapture {
|
||||
}
|
||||
}
|
||||
static bool Start(void* self, NativeSharedSink* sink) {
|
||||
auto* capture = g_native_capture.load(std::memory_order_acquire);
|
||||
auto capture =
|
||||
std::atomic_load_explicit(&g_native_capture, std::memory_order_acquire);
|
||||
return capture && capture->StartSink(self, sink);
|
||||
}
|
||||
static void Stop(void* self, NativeSharedSink* sink) {
|
||||
auto* capture = g_native_capture.load(std::memory_order_acquire);
|
||||
auto capture =
|
||||
std::atomic_load_explicit(&g_native_capture, std::memory_order_acquire);
|
||||
if (capture) capture->StopSink(self, sink);
|
||||
}
|
||||
static bool Recording(void* self) {
|
||||
auto* capture = g_native_capture.load(std::memory_order_acquire);
|
||||
auto capture =
|
||||
std::atomic_load_explicit(&g_native_capture, std::memory_order_acquire);
|
||||
if (!capture) return false;
|
||||
std::lock_guard lock(capture->mutex_);
|
||||
return capture->sessions_.find(self) != capture->sessions_.end();
|
||||
}
|
||||
static void Poll(void* self) {
|
||||
auto* capture = g_native_capture.load(std::memory_order_acquire);
|
||||
auto capture =
|
||||
std::atomic_load_explicit(&g_native_capture, std::memory_order_acquire);
|
||||
if (capture) capture->Deliver(self);
|
||||
}
|
||||
void Shutdown() {
|
||||
std::lock_guard lock(mutex_);
|
||||
closed_ = true;
|
||||
for (auto& [self, session] : sessions_) Close(*session);
|
||||
sessions_.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
struct Sink {
|
||||
NativeSharedSink shared;
|
||||
DeliverPcm deliver;
|
||||
};
|
||||
struct SharedCount {
|
||||
const std::uintptr_t* vtable;
|
||||
long shared_owners;
|
||||
long weak_owners;
|
||||
};
|
||||
using ControlBlockHook = void (*)(void*);
|
||||
struct Session {
|
||||
std::unique_ptr<AudioCapture> input;
|
||||
std::vector<NativeSharedSink> sinks;
|
||||
std::vector<Sink> sinks;
|
||||
std::mutex queue_mutex;
|
||||
// At most 200 ms; a stalled consumer must not accumulate stale speech.
|
||||
std::array<std::array<std::int16_t, 480>, 20> frames{};
|
||||
@@ -118,20 +139,33 @@ class NativeInputCapture {
|
||||
session.input->buffer_data(), bytes);
|
||||
++session.count;
|
||||
}
|
||||
bool IsGuestVtable(const void* object, std::size_t size,
|
||||
std::initializer_list<std::size_t> methods) const {
|
||||
const auto base = abi_.image_base;
|
||||
const auto* table = *static_cast<const std::uintptr_t* const*>(object);
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(table);
|
||||
if (address < base ||
|
||||
!abi_.is_image_relro(base, address - base, size * sizeof(*table)))
|
||||
return false;
|
||||
for (const auto slot : methods)
|
||||
if (table[slot] < base ||
|
||||
!abi_.is_image_code(base, table[slot] - base, 1))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool StartSink(void* self, NativeSharedSink* sink) {
|
||||
std::lock_guard lock(mutex_);
|
||||
if (!enabled_ || !self || !sink || !sink->object || !sink->owner)
|
||||
if (closed_ || !enabled_ || !self || !sink || !sink->object || !sink->owner)
|
||||
return false;
|
||||
auto* table = *reinterpret_cast<std::uintptr_t**>(sink->object);
|
||||
if (reinterpret_cast<std::uintptr_t>(table) != abi_.vtable ||
|
||||
table[2] != reinterpret_cast<std::uintptr_t>(abi_.deliver)) {
|
||||
if (!IsGuestVtable(sink->object, 3, {2}) ||
|
||||
!IsGuestVtable(sink->owner, 5, {2, 4})) {
|
||||
std::fprintf(stderr, " [audio-input] unsupported native PCM sink ABI\n");
|
||||
return false;
|
||||
}
|
||||
auto it = sessions_.find(self);
|
||||
if (it != sessions_.end()) {
|
||||
for (const auto& existing : it->second->sinks)
|
||||
if (existing.object == sink->object) return true;
|
||||
if (existing.shared.object == sink->object) return true;
|
||||
} else {
|
||||
auto session = std::make_unique<Session>();
|
||||
SdlAudioCaptureOptions options;
|
||||
@@ -151,13 +185,20 @@ class NativeInputCapture {
|
||||
}
|
||||
// The native parameter is a by-value shared_ptr. Retain its existing
|
||||
// ownership by moving it, leaving the caller's temporary empty.
|
||||
it->second->sinks.push_back(*sink);
|
||||
const auto* table = *static_cast<const std::uintptr_t* const*>(sink->object);
|
||||
it->second->sinks.push_back({*sink, reinterpret_cast<DeliverPcm>(table[2])});
|
||||
*sink = {};
|
||||
return true;
|
||||
}
|
||||
void Release(NativeSharedSink& sink) {
|
||||
abi_.release(&sink);
|
||||
static void Release(Sink& sink) {
|
||||
auto* count = static_cast<SharedCount*>(sink.shared.owner);
|
||||
sink = {};
|
||||
if (__atomic_fetch_sub(&count->shared_owners, 1, __ATOMIC_ACQ_REL) != 0)
|
||||
return;
|
||||
reinterpret_cast<ControlBlockHook>(count->vtable[2])(count);
|
||||
if (__atomic_load_n(&count->weak_owners, __ATOMIC_ACQUIRE) == 0 ||
|
||||
__atomic_fetch_sub(&count->weak_owners, 1, __ATOMIC_ACQ_REL) == 0)
|
||||
reinterpret_cast<ControlBlockHook>(count->vtable[4])(count);
|
||||
}
|
||||
void Close(Session& session) {
|
||||
session.input->Shutdown();
|
||||
@@ -174,7 +215,7 @@ class NativeInputCapture {
|
||||
if (it == sessions_.end() || !sink) return;
|
||||
auto& session = *it->second;
|
||||
auto existing = std::find_if(session.sinks.begin(), session.sinks.end(),
|
||||
[&](const auto& entry) { return entry.object == sink->object; });
|
||||
[&](const auto& entry) { return entry.shared.object == sink->object; });
|
||||
if (existing == session.sinks.end()) return;
|
||||
Release(*existing);
|
||||
session.sinks.erase(existing);
|
||||
@@ -203,8 +244,7 @@ class NativeInputCapture {
|
||||
}
|
||||
const NativePcmFormat format;
|
||||
for (const auto& sink : session.sinks)
|
||||
abi_.deliver(
|
||||
sink.object, pcm.data(), pcm.size(), delay, &format);
|
||||
sink.deliver(sink.shared.object, pcm.data(), pcm.size(), delay, &format);
|
||||
if (++session.delivered == 1)
|
||||
std::fprintf(stderr, " [audio-input] PCM delivered to native voice sink\n");
|
||||
if (!session.audible && std::any_of(pcm.begin(), pcm.end(),
|
||||
@@ -216,6 +256,7 @@ class NativeInputCapture {
|
||||
}
|
||||
SinkAbi abi_;
|
||||
bool enabled_;
|
||||
bool closed_ = false;
|
||||
std::mutex mutex_;
|
||||
std::map<void*, std::unique_ptr<Session>> sessions_;
|
||||
};
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
#include <mutex>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace mocktail::audio {
|
||||
namespace {
|
||||
@@ -55,10 +53,8 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
};
|
||||
|
||||
struct ReleaseTicket {
|
||||
std::shared_ptr<State> state;
|
||||
std::uint64_t id = 0;
|
||||
std::uint64_t generation = 0;
|
||||
bool in_use = false;
|
||||
const std::shared_ptr<State> state;
|
||||
const std::uint64_t generation;
|
||||
};
|
||||
|
||||
struct CallbackJob {
|
||||
@@ -71,13 +67,7 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
: sink(std::move(owned_sink)),
|
||||
max_buffers(options.max_buffers),
|
||||
event_callback(options.event_callback),
|
||||
event_context(options.event_context),
|
||||
ticket_pool(options.max_buffers) {
|
||||
free_tickets.reserve(options.max_buffers);
|
||||
for (std::size_t i = options.max_buffers; i > 0; --i) {
|
||||
free_tickets.push_back(i - 1);
|
||||
}
|
||||
}
|
||||
event_context(options.event_context) {}
|
||||
|
||||
static const AndroidSimpleBufferQueueTable kQueueTable;
|
||||
|
||||
@@ -103,7 +93,6 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
const std::shared_ptr<State> state = raw_state->shared_from_this();
|
||||
|
||||
std::lock_guard<std::mutex> operation_lock(state->sink_operation_mutex);
|
||||
std::uint64_t id = 0;
|
||||
ReleaseTicket* ticket = nullptr;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state->mutex);
|
||||
@@ -111,24 +100,24 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
return opensl_abi::kResultPreconditionsViolated;
|
||||
}
|
||||
if (state->pending_count.load(std::memory_order_relaxed) >=
|
||||
state->max_buffers ||
|
||||
state->free_tickets.empty()) {
|
||||
state->max_buffers) {
|
||||
return opensl_abi::kResultBufferInsufficient;
|
||||
}
|
||||
const std::size_t slot_index = state->free_tickets.back();
|
||||
state->free_tickets.pop_back();
|
||||
ticket = &state->ticket_pool[slot_index];
|
||||
id = state->next_id++;
|
||||
ticket->state = state;
|
||||
ticket->id = id;
|
||||
ticket->generation = state->generation;
|
||||
ticket->in_use = true;
|
||||
ticket = new (std::nothrow)
|
||||
ReleaseTicket{state, state->generation};
|
||||
if (ticket == nullptr) {
|
||||
state->last_status = Status::Error(
|
||||
StatusCode::kUnavailable, "unable to allocate OpenSL release ticket");
|
||||
return ToOpenSlResult(state->last_status);
|
||||
}
|
||||
state->pending_count.fetch_add(1, std::memory_order_relaxed);
|
||||
++state->submitted_buffers;
|
||||
}
|
||||
|
||||
const PcmBuffer pcm{buffer, static_cast<std::size_t>(size),
|
||||
&State::ReleaseBuffer, ticket};
|
||||
// A successful enqueue may release synchronously. Only a failed enqueue
|
||||
// leaves ownership here; its contract forbids a release callback.
|
||||
const Status status = state->sink->Enqueue(pcm);
|
||||
if (status.ok()) {
|
||||
state->NotifyEvent(OpenSlBufferQueueEvent::kSubmitted,
|
||||
@@ -136,22 +125,12 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
return opensl_abi::kResultSuccess;
|
||||
}
|
||||
|
||||
const std::unique_ptr<ReleaseTicket> failed_ticket(ticket);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state->mutex);
|
||||
state->last_status = status;
|
||||
if (ticket->in_use && ticket->id == id) {
|
||||
ticket->in_use = false;
|
||||
ticket->state.reset();
|
||||
const std::size_t slot_index =
|
||||
static_cast<std::size_t>(ticket - state->ticket_pool.data());
|
||||
state->free_tickets.push_back(slot_index);
|
||||
if (state->pending_count.load(std::memory_order_relaxed) > 0) {
|
||||
state->pending_count.fetch_sub(1, std::memory_order_relaxed);
|
||||
}
|
||||
if (state->submitted_buffers > 0) {
|
||||
--state->submitted_buffers;
|
||||
}
|
||||
}
|
||||
state->pending_count.fetch_sub(1, std::memory_order_relaxed);
|
||||
--state->submitted_buffers;
|
||||
}
|
||||
return ToOpenSlResult(status);
|
||||
}
|
||||
@@ -164,25 +143,14 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
}
|
||||
const std::shared_ptr<State> state = raw_state->shared_from_this();
|
||||
std::lock_guard<std::mutex> operation_lock(state->sink_operation_mutex);
|
||||
std::size_t discarded_count = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state->mutex);
|
||||
if (state->stopping) {
|
||||
return opensl_abi::kResultPreconditionsViolated;
|
||||
}
|
||||
++state->generation;
|
||||
state->free_tickets.clear();
|
||||
for (auto& ticket : state->ticket_pool) {
|
||||
if (ticket.in_use) {
|
||||
ticket.in_use = false;
|
||||
ticket.state.reset();
|
||||
++discarded_count;
|
||||
}
|
||||
}
|
||||
for (std::size_t i = state->max_buffers; i > 0; --i) {
|
||||
state->free_tickets.push_back(i - 1);
|
||||
}
|
||||
state->discarded_buffers += discarded_count;
|
||||
state->discarded_buffers +=
|
||||
state->pending_count.load(std::memory_order_relaxed);
|
||||
state->pending_count.store(0, std::memory_order_relaxed);
|
||||
}
|
||||
const Status status = state->sink->Clear();
|
||||
@@ -226,7 +194,8 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
|
||||
static void ReleaseBuffer(void* context, const void* /*data*/,
|
||||
std::size_t size_bytes) {
|
||||
auto* ticket = static_cast<ReleaseTicket*>(context);
|
||||
const std::unique_ptr<ReleaseTicket> ticket(
|
||||
static_cast<ReleaseTicket*>(context));
|
||||
if (ticket == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -239,29 +208,27 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
bool discarded = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state->mutex);
|
||||
if (ticket->in_use) {
|
||||
ticket->in_use = false;
|
||||
ticket->state.reset();
|
||||
const std::size_t slot_index =
|
||||
static_cast<std::size_t>(ticket - state->ticket_pool.data());
|
||||
state->free_tickets.push_back(slot_index);
|
||||
if (state->pending_count.load(std::memory_order_relaxed) > 0) {
|
||||
state->pending_count.fetch_sub(1, std::memory_order_relaxed);
|
||||
}
|
||||
if (!state->stopping && ticket->generation == state->generation) {
|
||||
state->processed_buffers.fetch_add(1, std::memory_order_relaxed);
|
||||
++state->consumed_buffers;
|
||||
state->consumed_bytes += size_bytes;
|
||||
consumed = true;
|
||||
if (state->callback != nullptr) {
|
||||
state->callback_jobs.push_back(
|
||||
CallbackJob{state->callback, state->callback_context});
|
||||
notify_worker = true;
|
||||
}
|
||||
} else {
|
||||
++state->discarded_buffers;
|
||||
discarded = true;
|
||||
// Clear already counted older generations as discarded. Their tickets
|
||||
// remain alive until release without affecting newly enqueued buffers.
|
||||
if (ticket->generation != state->generation) {
|
||||
return;
|
||||
}
|
||||
if (state->pending_count.load(std::memory_order_relaxed) > 0) {
|
||||
state->pending_count.fetch_sub(1, std::memory_order_relaxed);
|
||||
}
|
||||
if (!state->stopping) {
|
||||
state->processed_buffers.fetch_add(1, std::memory_order_relaxed);
|
||||
++state->consumed_buffers;
|
||||
state->consumed_bytes += size_bytes;
|
||||
consumed = true;
|
||||
if (state->callback != nullptr) {
|
||||
state->callback_jobs.push_back(
|
||||
CallbackJob{state->callback, state->callback_context});
|
||||
notify_worker = true;
|
||||
}
|
||||
} else {
|
||||
++state->discarded_buffers;
|
||||
discarded = true;
|
||||
}
|
||||
}
|
||||
if (consumed) {
|
||||
@@ -374,14 +341,11 @@ struct OpenSlSimpleBufferQueueAdapter::State
|
||||
void* const event_context;
|
||||
Handle handle;
|
||||
pthread_t callback_thread{};
|
||||
std::vector<ReleaseTicket> ticket_pool;
|
||||
std::vector<std::size_t> free_tickets;
|
||||
std::atomic<std::size_t> pending_count{0};
|
||||
std::deque<CallbackJob> callback_jobs;
|
||||
AndroidSimpleBufferQueueCallback callback = nullptr;
|
||||
void* callback_context = nullptr;
|
||||
Status last_status;
|
||||
std::uint64_t next_id = 1;
|
||||
std::uint64_t generation = 1;
|
||||
std::atomic<std::uint64_t> processed_buffers{0};
|
||||
std::uint64_t submitted_buffers = 0;
|
||||
@@ -547,7 +511,6 @@ void OpenSlSimpleBufferQueueAdapter::Shutdown() {
|
||||
}
|
||||
state->shutdown_started = true;
|
||||
state->stopping = true;
|
||||
++state->generation;
|
||||
state->callback = nullptr;
|
||||
state->callback_context = nullptr;
|
||||
state->callback_jobs.clear();
|
||||
@@ -566,10 +529,6 @@ void OpenSlSimpleBufferQueueAdapter::Shutdown() {
|
||||
state->last_status = Status::Error(
|
||||
StatusCode::kPlatformError,
|
||||
"audio sink did not release all borrowed OpenSL buffers");
|
||||
for (auto& ticket : state->ticket_pool) {
|
||||
ticket.in_use = false;
|
||||
ticket.state.reset();
|
||||
}
|
||||
state->pending_count.store(0, std::memory_order_relaxed);
|
||||
}
|
||||
state->shutdown_complete = true;
|
||||
|
||||
Loaded 100 of 241 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user