@threenative/runtime-native 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +236 -1
- package/android/app/build.gradle.kts +37 -2
- package/android/app/src/main/java/com/mystral/engine/MystralActivity.java +62 -0
- package/android/build.gradle.kts +1 -1
- package/android/gradle/wrapper/gradle-wrapper.properties +2 -2
- package/package.json +15 -4
- package/scripts/asset-manifest.mjs +190 -0
- package/scripts/asset-preflight.mjs +137 -6
- package/scripts/bundle.mjs +25 -5
- package/scripts/check-android-16kb-alignment.mjs +413 -0
- package/scripts/desktop-distribution.mjs +1084 -0
- package/scripts/inspect-container-brand.mjs +748 -0
- package/scripts/install-prebuilt.mjs +56 -10
- package/scripts/package-android.mjs +478 -32
- package/scripts/package-desktop.mjs +191 -15
- package/scripts/package-ios.mjs +53 -10
- package/scripts/production-evidence.mjs +7 -3
- package/scripts/profile-production.mjs +109 -28
- package/scripts/verify-starter-consumer.mjs +732 -0
- package/scripts/verify-starter-desktop-base.mjs +448 -0
- package/scripts/verify-starter-desktop.mjs +27 -220
- package/scripts/verify-windows-installer.mjs +63 -0
- package/scripts/windows-installer.mjs +181 -0
- package/scripts/windows-installer.nsi +114 -0
- package/scripts/xvfb.sh +48 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## What it is
|
|
4
4
|
|
|
5
5
|
`@threenative/runtime-native` is the optional ThreeNative host for running the same portable game
|
|
6
|
-
entry on desktop,
|
|
6
|
+
entry on desktop (Windows, macOS, Linux) and Android. iOS is not a supported target yet. Native compilation is opt-in: installing this package does
|
|
7
7
|
not require CMake, an NDK, or Xcode. It is a host, not a second renderer or scene API; upstream
|
|
8
8
|
Three.js and the game's `src/game.ts` remain the portable runtime contract.
|
|
9
9
|
|
|
@@ -56,6 +56,241 @@ inside that checkout.
|
|
|
56
56
|
If you have no engine checkout, the prebuilt path above is your path — `THREENATIVE_RUNTIME_SOURCE`
|
|
57
57
|
is not a way around a failing download.
|
|
58
58
|
|
|
59
|
+
## Desktop release containers and player prerequisites
|
|
60
|
+
|
|
61
|
+
`build --target desktop` produces the raw host executable by default. `--mode release` wraps the
|
|
62
|
+
compiled executable, the built `ui/` bundle and the shared libraries that executable actually loads
|
|
63
|
+
into one relocatable container for the host OS:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
pnpm exec threenative build --target desktop --mode release
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- **Linux** — a `tar.gz` with the executable, `ui/`, non-system libraries under `lib/`, and a
|
|
70
|
+
`.desktop` entry plus icon under `share/`.
|
|
71
|
+
- **macOS** — a `<Name>.app` inside a ZIP, with `Contents/MacOS/<exe>`, `Contents/Resources` and an
|
|
72
|
+
`Info.plist` carrying the game's id, name, version and build.
|
|
73
|
+
- **Windows** — a portable ZIP and a `*-setup.exe` installer, both carrying `<Name>.exe` (icon and
|
|
74
|
+
version embedded), `ui/` and non-system DLLs. Setup installs per user, creates a Start Menu
|
|
75
|
+
shortcut and registers an uninstaller in Windows Settings. Upgrades remove obsolete owned files;
|
|
76
|
+
uninstall preserves unrelated files. Uninstall the existing copy before choosing another directory.
|
|
77
|
+
|
|
78
|
+
Each container carries `threenative-container.json`: the app identity, the executable, every
|
|
79
|
+
bundled dependency with a SHA-256, and every system library recorded as a player prerequisite. All
|
|
80
|
+
of it resolves relative to the container root, so a container can be unpacked and moved anywhere; a
|
|
81
|
+
resource that is missing or whose bytes changed is refused. Release containers are unsigned unless
|
|
82
|
+
signing is configured. Signed macOS apps seal their manifest and executable with the application
|
|
83
|
+
signature; verification checks that signature as well as the resource hashes.
|
|
84
|
+
|
|
85
|
+
### Player prerequisites
|
|
86
|
+
|
|
87
|
+
The container does not ship the platform's WebView or windowing stack. The player machine provides:
|
|
88
|
+
|
|
89
|
+
| OS | Prerequisite | Install |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| Linux | WebKitGTK 4.1 and GTK 3 | Debian/Ubuntu: `sudo apt-get install -y libwebkit2gtk-4.1-0 libgtk-3-0`; Fedora: `sudo dnf install webkit2gtk4.1 gtk3`; Arch: `sudo pacman -S webkit2gtk-4.1 gtk3` |
|
|
92
|
+
| Windows | Microsoft Edge WebView2 Evergreen Runtime, when WebUI is selected | Setup checks for it and installs it if missing (internet required); portable ZIP users install it from <https://developer.microsoft.com/microsoft-edge/webview2/> |
|
|
93
|
+
| macOS | System WebKit | included with macOS |
|
|
94
|
+
|
|
95
|
+
The verifier inspects an unpacked container and resolves its integrity records first. On Linux it
|
|
96
|
+
also resolves every shared library the executable loads and refuses to launch when a recorded
|
|
97
|
+
prerequisite is missing, naming the library with its install step rather than a bare loader error.
|
|
98
|
+
On Windows the installer checks WebView2 before installing the game; the portable ZIP verifier does
|
|
99
|
+
not check it. macOS includes the system WebKit used by the overlay.
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
node node_modules/@threenative/runtime-native/scripts/verify-starter-desktop.mjs --container <unpacked-directory>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Packaging prerequisites (the developer's machine)
|
|
106
|
+
|
|
107
|
+
`--mode release` shells out to OS tools to build the container and stamp the game's identity into
|
|
108
|
+
it. They are needed on the machine that packages the game, never on the player's:
|
|
109
|
+
|
|
110
|
+
| OS | Tool | Needed for | Install |
|
|
111
|
+
| --- | --- | --- | --- |
|
|
112
|
+
| Linux | `tar` | the `tar.gz` container | included with the distribution |
|
|
113
|
+
| macOS | `zip` | the `.zip` container | included with macOS |
|
|
114
|
+
| macOS | `sips`, `iconutil` | converting `app.icon` into the `.icns` the `.app` bundle carries | included with macOS |
|
|
115
|
+
| Windows | `zip` | the `.zip` container | `choco install zip` |
|
|
116
|
+
| Windows | NSIS 3 (`makensis`) | the `*-setup.exe` installer | `choco install nsis --version=3.11.0`; the packager also finds the standard Program Files installation |
|
|
117
|
+
| Windows | `rcedit` | embedding `app.icon` and the version strings into the executable's PE resources | <https://github.com/electron/rcedit/releases>, with `rcedit.exe` on `PATH` |
|
|
118
|
+
| Windows | `dumpbin` | listing the DLLs the executable imports, so the container records them and stays relocatable | ships with Visual Studio; run the release build from a Developer Command Prompt |
|
|
119
|
+
|
|
120
|
+
A missing tool refuses the release with `TN_DESKTOP_ARCHIVE_TOOL_MISSING` or
|
|
121
|
+
`TN_DESKTOP_RESOURCE_TOOL_MISSING` naming the tool, rather than shipping a container without the
|
|
122
|
+
identity it claims. NSIS failures report `TN_WINDOWS_INSTALLER_FAILED`. The icon tools are required
|
|
123
|
+
only when `app.icon` is configured. Windows WebUI packaging downloads Microsoft's signed WebView2
|
|
124
|
+
bootstrapper and verifies its Authenticode signature before embedding it; this build needs internet.
|
|
125
|
+
|
|
126
|
+
### Standard distribution recipe
|
|
127
|
+
|
|
128
|
+
1. Build: `pnpm exec threenative build --target desktop --mode release`.
|
|
129
|
+
2. Verify the extracted container from the installed project:
|
|
130
|
+
`node node_modules/@threenative/runtime-native/scripts/verify-starter-desktop.mjs --container <unpacked-directory> --config <project>/.threenative/build/config.json`.
|
|
131
|
+
`--config` points the verifier at the resolved consumer config the build already wrote, and the
|
|
132
|
+
container's launcher name, embedded icon and declared loading sequence are then inspected before
|
|
133
|
+
anything launches — on Windows by reading the executable's own `RT_GROUP_ICON`/`RT_ICON` and
|
|
134
|
+
`RT_VERSION` resources, not the manifest beside it. Without `--config` the gate says
|
|
135
|
+
`brand NOT inspected` rather than implying the identity was checked.
|
|
136
|
+
3. Configure signing before building where required (below), then distribute the installer or archive.
|
|
137
|
+
|
|
138
|
+
Run your game's input and gameplay assertions against the extracted executable on Linux, macOS or
|
|
139
|
+
Windows with the installed runner:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
node node_modules/@threenative/playtest/dist/runner/cli.js playtests/production-readiness.playtest.json --target desktop --executable <unpacked-executable> --project . --host-arg --windowed
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
For macOS, the executable is inside `<game>.app/Contents/MacOS/`. These verification commands need
|
|
146
|
+
Node; launching the packaged game itself does not. CI also runs React pause/resume and movement
|
|
147
|
+
assertions against the relocated macOS release and the installed Windows release.
|
|
148
|
+
|
|
149
|
+
On Windows, test the actual installer with a scenario from your game:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
node node_modules/@threenative/runtime-native/scripts/verify-windows-installer.mjs --installer dist-native/my-game-setup.exe --project . --scenario scenarios/production-readiness.playtest.json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
This command installs into a temporary directory containing spaces, checks the installed manifest,
|
|
156
|
+
runs the existing playtest runner against that exact executable, and uninstalls it. Signed builds
|
|
157
|
+
also require `signtool` to verify the setup, game and uninstaller signatures. Every packaged file
|
|
158
|
+
must be removed. Runtime-created files are preserved and their paths and retained directory are
|
|
159
|
+
printed; directory links are listed without traversal. Failures also retain the temporary directory
|
|
160
|
+
and print its path. In this repository, use `pnpm native:verify:windows:installer`
|
|
161
|
+
with the same arguments. Add `--require-signed` to reject an unsigned release explicitly.
|
|
162
|
+
|
|
163
|
+
### Measure visible React UI latency
|
|
164
|
+
|
|
165
|
+
From this engine checkout on Linux, use an installed game's dependencies and a built native host:
|
|
166
|
+
|
|
167
|
+
```sh
|
|
168
|
+
pnpm native:verify:ui --project /absolute/path/to/game --runtime packages/runtime-native/build/tn-linux/mystral
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The command builds a small 60 FPS React fixture with the installed CLI's release command, extracts
|
|
172
|
+
the final archive into a new location, checks its integrity, and captures its visible state IDs at
|
|
173
|
+
240 Hz using Xvfb and FFmpeg. It requires p95 publication-to-visible latency at most 50 ms, at least
|
|
174
|
+
50 visible updates in each measured active second, and two idle wake-ups within 67 ms. Capture
|
|
175
|
+
delivery delay is included. An attached overlay or fast React commits alone cannot pass this check.
|
|
176
|
+
The desktop capture backend qualifies Linux/X11 only; it does not measure a physical monitor's refresh rate.
|
|
177
|
+
|
|
178
|
+
For Android, select an online 60 Hz emulator or device and provide the same release signing
|
|
179
|
+
environment used by `threenative build --target android --mode release`:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
pnpm native:verify:ui --target android --project /absolute/path/to/game --device <serial>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
This builds, verifies and installs the final signed APK, checks its installed SHA-256, and records
|
|
186
|
+
27 seconds through Android's `screenrecord`. Exact visible state IDs are matched to its Winscope v2
|
|
187
|
+
timestamps and checked against decoded frame timestamps. The same 50 ms latency and visible-update
|
|
188
|
+
bounds apply. This measures captured SurfaceFlinger composition, not physical scanout. At Android's
|
|
189
|
+
60 Hz capture rate, unobserved IDs can be sampling misses; they are reported separately from UI drops.
|
|
190
|
+
Missing metadata, invalid pixels or inadequate capture cadence fail the command. `--allow-source-build`
|
|
191
|
+
explicitly permits the installed builder's source fallback when required native prebuilts are absent.
|
|
192
|
+
|
|
193
|
+
Results, raw observations, a screenshot and the final archive are retained under
|
|
194
|
+
`artifacts/ui-cadence/<timestamp>/`. Use `--artifacts <empty-directory>` to choose the location;
|
|
195
|
+
nonempty directories are refused so a failed rerun cannot inherit a passing result. Successful runs
|
|
196
|
+
remove their temporary fixture project; failures retain it and print its path. To repeat a packaged
|
|
197
|
+
fixture, use `--executable <extracted-fixture-executable>` on desktop, or
|
|
198
|
+
`--target android --apk <packaged-fixture.apk> --device <serial>` on Android. These inputs must be the
|
|
199
|
+
command's cadence fixture, not an arbitrary game. Both backends require FFmpeg; Android also requires
|
|
200
|
+
`ffprobe` and ADB, and Linux requires Xvfb. Allow about 40 seconds on Linux or 60 seconds on Android
|
|
201
|
+
after dependencies and the release artifact build.
|
|
202
|
+
|
|
203
|
+
### Signing and store/depot handoff
|
|
204
|
+
|
|
205
|
+
A release container is complete but unsigned. Non-secret inputs come from the build environment,
|
|
206
|
+
while the private key and the notarytool password stay in the OS keychain and are never written into
|
|
207
|
+
the container. Setting `THREENATIVE_DESKTOP_SIGN=1`, or providing an identity, certificate, store subject or
|
|
208
|
+
notary profile, requests signing; with none of them, release stays unsigned. A variable set to
|
|
209
|
+
an empty or blank value counts as absent, so an unset CI secret leaves an unsigned container
|
|
210
|
+
rather than failing the release.
|
|
211
|
+
|
|
212
|
+
| Variable | Meaning |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| `THREENATIVE_DESKTOP_SIGN` | `1`/`true` requests a signed release; macOS/Windows without the matching inputs fail as PENDING. |
|
|
215
|
+
| `THREENATIVE_DESKTOP_CODESIGN_IDENTITY` | macOS `codesign` Developer ID identity. |
|
|
216
|
+
| `THREENATIVE_DESKTOP_NOTARY_PROFILE` | macOS `notarytool` keychain profile; enables notarization and stapling. |
|
|
217
|
+
| `THREENATIVE_DESKTOP_SIGN_CERTIFICATE` | Windows code-signing certificate (`.pfx`), password-less. |
|
|
218
|
+
| `THREENATIVE_DESKTOP_SIGN_SUBJECT` | Windows certificate-store subject name; the private key stays in the store. |
|
|
219
|
+
| `THREENATIVE_DESKTOP_TIMESTAMP_URL` | Windows Authenticode timestamp server. |
|
|
220
|
+
|
|
221
|
+
Windows `signtool` signs and verifies the game, setup and embedded uninstaller. Prefer
|
|
222
|
+
`THREENATIVE_DESKTOP_SIGN_SUBJECT`: it signs with `/n`, so the private key never leaves the store.
|
|
223
|
+
`THREENATIVE_DESKTOP_SIGN_CERTIFICATE` uses `/f` and is passed no password, so it only works for a
|
|
224
|
+
password-less `.pfx`. Setting both is refused rather than silently resolved.
|
|
225
|
+
|
|
226
|
+
**There is deliberately no password variable.** Since the CA/Browser Forum tightened its code-signing
|
|
227
|
+
requirements in 2023, a publicly trusted code-signing key has to be generated and held on certified
|
|
228
|
+
hardware — a token, an HSM, or a cloud signing service — so a certificate authority does not hand
|
|
229
|
+
over a `.pfx` for you to protect with a password in the first place. Adding `/p` would carry a
|
|
230
|
+
secret through the build environment to serve a case that modern issuance does not produce. The
|
|
231
|
+
store subject is the supported route; the `/f` form remains for a self-signed or internally issued
|
|
232
|
+
password-less file.
|
|
233
|
+
|
|
234
|
+
Two things about `/n` that decide whether a build machine can sign at all. It searches the
|
|
235
|
+
**`CurrentUser\My`** store only — a certificate imported into `LocalMachine` is not found, and
|
|
236
|
+
signtool reports `No certificates were found that met all the given criteria`. And the subject is
|
|
237
|
+
matched as a **substring**, so a value that hits several certificates lets signtool pick among them;
|
|
238
|
+
give a subject specific enough to match one. The machine store (`/sm`) and cloud or HSM signing
|
|
239
|
+
(`/csp` with `/kc`, or `/dlib` for Azure Trusted Signing and similar) are not reachable through this
|
|
240
|
+
contract. macOS `codesign` signs and verifies the
|
|
241
|
+
bundle, `notarytool` notarizes the archive and `stapler` staples the ticket; a notarization Apple did
|
|
242
|
+
not accept is refused, and an evidence record whose artifact hash is not the produced artifact is
|
|
243
|
+
rejected. Linux has no Authenticode or notarization, so it proceeds unsigned with integrity metadata
|
|
244
|
+
only and is handed to the package/depot step as-is. A signing failure refuses the release and leaves
|
|
245
|
+
no archive, and the manifest records `signed` so an unsigned preparation is never mistaken for a
|
|
246
|
+
signed one. These toolchains run only on their own OS: the repository's Linux tests exercise them
|
|
247
|
+
through fixture transport, so a real signed or notarized artifact must be produced and verified on a
|
|
248
|
+
Windows or macOS host.
|
|
249
|
+
|
|
250
|
+
## Release builds and signing
|
|
251
|
+
|
|
252
|
+
`build --target android` produces a debug APK by default. Release output is an explicit request:
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
pnpm exec threenative build --target android --mode release --format apk # signed APK
|
|
256
|
+
pnpm exec threenative build --target android --mode release --format aab # Play app bundle
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
A release is signed with **your** key. There is no debug-key fallback: when signing is not
|
|
260
|
+
configured the packager refuses the release rather than shipping an unsigned or debug-signed
|
|
261
|
+
artifact. Supply the key as the four Gradle project properties below, from the game's build
|
|
262
|
+
environment. Paths are resolved relative to the project; nothing is written into the engine.
|
|
263
|
+
|
|
264
|
+
| Environment variable | Meaning |
|
|
265
|
+
| --- | --- |
|
|
266
|
+
| `ORG_GRADLE_PROJECT_threenativeKeystore` | Path to the keystore (`.jks`/`.keystore`). |
|
|
267
|
+
| `ORG_GRADLE_PROJECT_threenativeKeystoreAlias` | Key alias inside the keystore. |
|
|
268
|
+
| `ORG_GRADLE_PROJECT_threenativeKeystorePassword` | Keystore password. |
|
|
269
|
+
| `ORG_GRADLE_PROJECT_threenativeKeyPassword` | Key password. |
|
|
270
|
+
|
|
271
|
+
Passwords reach signing subprocesses through environment variables, including APK realignment;
|
|
272
|
+
they are never placed in command arguments or packaging output. The final APK is verified with `apksigner`, and its packaged `targetSdkVersion`
|
|
273
|
+
and non-debuggable state are read back with `aapt`; a release AAB is verified with `jarsigner -strict`.
|
|
274
|
+
Missing signatures and unsigned entries fail; Android's self-signed upload certificates are accepted. A
|
|
275
|
+
signature, target level or debuggable check that cannot be satisfied fails the build. Native symbols
|
|
276
|
+
are stripped from the artifact by the Android Gradle plugin and are produced separately for symbol
|
|
277
|
+
archives.
|
|
278
|
+
|
|
279
|
+
The Android build uses AGP 8.11.1 and Gradle 8.13 for API 36 and 16 KB bundle packaging.
|
|
280
|
+
Verify an APK's native libraries and archive offsets from the repository with
|
|
281
|
+
`pnpm native:verify:android:artifact /path/to/game.apk`. For an AAB, the same command generates
|
|
282
|
+
and inspects a universal APK using Google's [bundletool](https://github.com/google/bundletool/releases):
|
|
283
|
+
|
|
284
|
+
```sh
|
|
285
|
+
pnpm native:verify:android:artifact /path/to/game.aab --bundletool /path/to/bundletool-all.jar
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Inside an installed game, replace `pnpm native:verify:android:artifact` with
|
|
289
|
+
`node node_modules/@threenative/runtime-native/scripts/check-android-16kb-alignment.mjs`.
|
|
290
|
+
The AAB stays unchanged; bundletool uses its standard debug key for the temporary inspection APK.
|
|
291
|
+
This checks every packaged ABI's ELF alignment and APK offsets; it does not replace installing and
|
|
292
|
+
playing the signed release on a 16 KB Android emulator or device.
|
|
293
|
+
|
|
59
294
|
## Links
|
|
60
295
|
|
|
61
296
|
- [Repository](https://github.com/ThreeNativeHQ/threenative)
|
|
@@ -293,15 +293,34 @@ dependencies {
|
|
|
293
293
|
implementation("androidx.webkit:webkit:1.12.1")
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
// PRD-212 phase 3. Release signing is owned by the game, never by the engine: these four project
|
|
297
|
+
// properties arrive from the consumer's build environment as ORG_GRADLE_PROJECT_<name>, so no
|
|
298
|
+
// keystore path or password is ever written into an engine file. When all four are present the
|
|
299
|
+
// release variant is signed with them; when any is missing the release stays unsigned and
|
|
300
|
+
// `package-android.mjs` refuses it. There is deliberately no debug-key fallback.
|
|
301
|
+
val threenativeKeystore = providers.gradleProperty("threenativeKeystore")
|
|
302
|
+
val threenativeKeystoreAlias = providers.gradleProperty("threenativeKeystoreAlias")
|
|
303
|
+
val threenativeKeystorePassword = providers.gradleProperty("threenativeKeystorePassword")
|
|
304
|
+
val threenativeKeyPassword = providers.gradleProperty("threenativeKeyPassword")
|
|
305
|
+
val hasReleaseSigning =
|
|
306
|
+
threenativeKeystore.isPresent &&
|
|
307
|
+
threenativeKeystoreAlias.isPresent &&
|
|
308
|
+
threenativeKeystorePassword.isPresent &&
|
|
309
|
+
threenativeKeyPassword.isPresent
|
|
310
|
+
|
|
296
311
|
android {
|
|
297
312
|
namespace = "com.threenative.game"
|
|
298
|
-
|
|
313
|
+
// Google Play requires new apps and updates to target API 36 (Android 16) from 2026-08-31;
|
|
314
|
+
// API 35 submissions are rejected. compileSdk and targetSdk move together: compiling against
|
|
315
|
+
// one platform while targeting another is how an API-36-only symbol silently ships.
|
|
316
|
+
// Required by PRD-212 phase 1.
|
|
317
|
+
compileSdk = 36
|
|
299
318
|
ndkVersion = "28.2.13676358"
|
|
300
319
|
|
|
301
320
|
defaultConfig {
|
|
302
321
|
applicationId = "com.threenative.game"
|
|
303
322
|
minSdk = 24 // Android 7.0 - minimum for Vulkan
|
|
304
|
-
targetSdk =
|
|
323
|
+
targetSdk = 36
|
|
305
324
|
versionCode = 1
|
|
306
325
|
versionName = "0.1.0"
|
|
307
326
|
|
|
@@ -378,6 +397,17 @@ android {
|
|
|
378
397
|
}
|
|
379
398
|
}
|
|
380
399
|
|
|
400
|
+
signingConfigs {
|
|
401
|
+
create("release") {
|
|
402
|
+
if (hasReleaseSigning) {
|
|
403
|
+
storeFile = file(threenativeKeystore.get())
|
|
404
|
+
storePassword = threenativeKeystorePassword.get()
|
|
405
|
+
keyAlias = threenativeKeystoreAlias.get()
|
|
406
|
+
keyPassword = threenativeKeyPassword.get()
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
381
411
|
buildTypes {
|
|
382
412
|
debug {
|
|
383
413
|
// AGP pins the debug variant's native build to CMAKE_BUILD_TYPE=Debug and ignores
|
|
@@ -393,6 +423,11 @@ android {
|
|
|
393
423
|
}
|
|
394
424
|
}
|
|
395
425
|
release {
|
|
426
|
+
// PRD-212: a release artifact is never debuggable, whatever the default becomes. The
|
|
427
|
+
// debug variant stays the install-anywhere default; release is opt-in and signed only
|
|
428
|
+
// by the consumer's own properties — never a debug key.
|
|
429
|
+
isDebuggable = false
|
|
430
|
+
if (hasReleaseSigning) signingConfig = signingConfigs.getByName("release")
|
|
396
431
|
isMinifyEnabled = false
|
|
397
432
|
proguardFiles(
|
|
398
433
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
@@ -7,6 +7,7 @@ import android.graphics.Insets;
|
|
|
7
7
|
import android.os.Build;
|
|
8
8
|
import android.os.Bundle;
|
|
9
9
|
import android.util.Log;
|
|
10
|
+
import android.view.Choreographer;
|
|
10
11
|
import android.view.Surface;
|
|
11
12
|
import android.view.SurfaceHolder;
|
|
12
13
|
import android.view.View;
|
|
@@ -33,6 +34,34 @@ public class MystralActivity extends SDLActivity {
|
|
|
33
34
|
/** The transparent WebView the UI renders into, or null when this game ships no overlay. */
|
|
34
35
|
private TnUiOverlay uiOverlay;
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The display-frame signal the native presentation cap aligns to (PRD-399). The native side
|
|
39
|
+
* sleeps to a deadline that has no relation to the display, so a state submitted just after
|
|
40
|
+
* the WebView's frame waits an extra vsync. Each doFrame hands the runtime that display
|
|
41
|
+
* frame's timestamp; the runtime paces to the measured cadence rather than an assumed 60 Hz.
|
|
42
|
+
*
|
|
43
|
+
* The callback is armed on resume and removed on pause, and it re-posts itself only while
|
|
44
|
+
* armed, so it can never outlive the activity that would receive its native call.
|
|
45
|
+
*/
|
|
46
|
+
private static native void nativeOnPresentationFrame(long frameTimeNanos);
|
|
47
|
+
|
|
48
|
+
private static native void nativeOnPresentationFramesStarted();
|
|
49
|
+
|
|
50
|
+
private static native void nativeOnPresentationFramesStopped();
|
|
51
|
+
|
|
52
|
+
private boolean presentationFramesArmed = false;
|
|
53
|
+
|
|
54
|
+
private final Choreographer.FrameCallback presentationFrame =
|
|
55
|
+
new Choreographer.FrameCallback() {
|
|
56
|
+
@Override
|
|
57
|
+
public void doFrame(long frameTimeNanos) {
|
|
58
|
+
nativeOnPresentationFrame(frameTimeNanos);
|
|
59
|
+
if (presentationFramesArmed) {
|
|
60
|
+
Choreographer.getInstance().postFrameCallback(this);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
36
65
|
/** Reapply the preference whenever Android replaces the drawable surface. */
|
|
37
66
|
private final SurfaceHolder.Callback frameRateCallback = new SurfaceHolder.Callback() {
|
|
38
67
|
@Override
|
|
@@ -89,9 +118,42 @@ public class MystralActivity extends SDLActivity {
|
|
|
89
118
|
@Override
|
|
90
119
|
protected void onResume() {
|
|
91
120
|
super.onResume();
|
|
121
|
+
armPresentationFrames();
|
|
92
122
|
if (mSurface != null) requestPreferredFrameRate(mSurface.getHolder(), applicationMetadata());
|
|
93
123
|
}
|
|
94
124
|
|
|
125
|
+
@Override
|
|
126
|
+
protected void onPause() {
|
|
127
|
+
// Notify the native waiter before removing the callback that would wake it: a render
|
|
128
|
+
// thread inside paceToPresentationCap() must fall back rather than wait out its timeout.
|
|
129
|
+
disarmPresentationFrames();
|
|
130
|
+
super.onPause();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Override
|
|
134
|
+
protected void onDestroy() {
|
|
135
|
+
// Belt and braces: a callback left registered when the native library unloads would call
|
|
136
|
+
// into freed code. onPause normally precedes this, so the guard makes it a no-op.
|
|
137
|
+
disarmPresentationFrames();
|
|
138
|
+
super.onDestroy();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Arm the display-frame callback once per foreground stretch, never twice. */
|
|
142
|
+
private void armPresentationFrames() {
|
|
143
|
+
if (presentationFramesArmed) return;
|
|
144
|
+
presentationFramesArmed = true;
|
|
145
|
+
nativeOnPresentationFramesStarted();
|
|
146
|
+
Choreographer.getInstance().postFrameCallback(presentationFrame);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Unblock the native waiter, then stop the callback that feeds it. */
|
|
150
|
+
private void disarmPresentationFrames() {
|
|
151
|
+
if (!presentationFramesArmed) return;
|
|
152
|
+
presentationFramesArmed = false;
|
|
153
|
+
nativeOnPresentationFramesStopped();
|
|
154
|
+
Choreographer.getInstance().removeFrameCallback(presentationFrame);
|
|
155
|
+
}
|
|
156
|
+
|
|
95
157
|
@Override
|
|
96
158
|
public void onTrimMemory(int level) {
|
|
97
159
|
// SDL's implementation below forwards a level-less SDL_EVENT_LOW_MEMORY. Capture the
|
package/android/build.gradle.kts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.
|
|
4
|
-
distributionSha256Sum=
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
|
4
|
+
distributionSha256Sum=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78
|
|
5
5
|
zipStoreBase=GRADLE_USER_HOME
|
|
6
6
|
zipStorePath=wrapper/dists
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threenative/runtime-native",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "ThreeNative-owned native host for desktop
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "ThreeNative-owned native host for desktop and Android",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"threenative",
|
|
7
7
|
"native",
|
|
@@ -42,10 +42,16 @@
|
|
|
42
42
|
"android/gradle/wrapper/gradle-wrapper.properties",
|
|
43
43
|
"android/gradlew",
|
|
44
44
|
"android/settings.gradle.kts",
|
|
45
|
+
"scripts/asset-manifest.mjs",
|
|
45
46
|
"scripts/asset-preflight.mjs",
|
|
46
47
|
"scripts/bundle.mjs",
|
|
48
|
+
"scripts/check-android-16kb-alignment.mjs",
|
|
47
49
|
"scripts/check-source-list.mjs",
|
|
50
|
+
"scripts/desktop-distribution.mjs",
|
|
51
|
+
"scripts/windows-installer.mjs",
|
|
52
|
+
"scripts/windows-installer.nsi",
|
|
48
53
|
"scripts/device-preflight.mjs",
|
|
54
|
+
"scripts/inspect-container-brand.mjs",
|
|
49
55
|
"scripts/install-prebuilt.mjs",
|
|
50
56
|
"scripts/package-android.mjs",
|
|
51
57
|
"scripts/package-desktop.mjs",
|
|
@@ -54,7 +60,10 @@
|
|
|
54
60
|
"scripts/production-evidence.mjs",
|
|
55
61
|
"scripts/profile-production.mjs",
|
|
56
62
|
"scripts/qualify-physical-mobile.mjs",
|
|
63
|
+
"scripts/verify-starter-consumer.mjs",
|
|
64
|
+
"scripts/verify-starter-desktop-base.mjs",
|
|
57
65
|
"scripts/verify-starter-desktop.mjs",
|
|
66
|
+
"scripts/verify-windows-installer.mjs",
|
|
58
67
|
"scripts/xvfb.sh"
|
|
59
68
|
],
|
|
60
69
|
"devDependencies": {
|
|
@@ -62,7 +71,7 @@
|
|
|
62
71
|
"publint": "0.3.22",
|
|
63
72
|
"three": "0.185.1",
|
|
64
73
|
"vitest": "4.1.10",
|
|
65
|
-
"@threenative/playtest": "0.3.
|
|
74
|
+
"@threenative/playtest": "0.3.3"
|
|
66
75
|
},
|
|
67
76
|
"dependencies": {
|
|
68
77
|
"pngjs": "7.0.0"
|
|
@@ -81,9 +90,11 @@
|
|
|
81
90
|
"native:physics:parity": "pnpm --dir ../.. exec vitest run packages/physics/__tests__/parity.spec.ts && cargo test --manifest-path native/physics/Cargo.toml --lib --test parity -- --nocapture",
|
|
82
91
|
"native:physics:parity:device": "node scripts/verify-android-physics-parity.mjs",
|
|
83
92
|
"native:qualify:physical": "node scripts/qualify-physical-mobile.mjs",
|
|
84
|
-
"native:verify:desktop": "node scripts/verify-desktop-audio.mjs && node scripts/verify-desktop-stability.mjs && node scripts/verify-desktop-core.mjs && node scripts/verify-desktop-physics.mjs && sh ../../scripts/xvfb.sh node scripts/verify-native-contracts.mjs && pnpm --dir ../playtest build && sh ../../scripts/xvfb.sh node scripts/verify-desktop-loading.mjs",
|
|
93
|
+
"native:verify:desktop": "node scripts/verify-desktop-audio.mjs && node scripts/verify-desktop-stability.mjs && node scripts/verify-desktop-core.mjs && node scripts/verify-desktop-physics.mjs && sh ../../scripts/xvfb.sh node scripts/verify-native-contracts.mjs && pnpm --dir ../playtest build && sh ../../scripts/xvfb.sh node scripts/verify-desktop-loading.mjs && sh ../../scripts/xvfb.sh node scripts/verify-desktop-ui-frame.mjs && vitest run --config vitest.config.ts tests/external-bundle-discovery.test.mjs",
|
|
85
94
|
"native:verify:loading": "pnpm --dir ../playtest build && sh ../../scripts/xvfb.sh node scripts/verify-desktop-loading.mjs",
|
|
95
|
+
"native:verify:ui-frame": "pnpm --dir ../playtest build && sh ../../scripts/xvfb.sh node scripts/verify-desktop-ui-frame.mjs",
|
|
86
96
|
"native:verify:android:multitouch": "pnpm --dir ../playtest build && node scripts/verify-android-multitouch.mjs",
|
|
97
|
+
"native:verify:android:artifact": "node scripts/check-android-16kb-alignment.mjs",
|
|
87
98
|
"profile:production": "node scripts/profile-production.mjs",
|
|
88
99
|
"parity": "node conformance/run-conformance.mjs",
|
|
89
100
|
"install": "node scripts/install-prebuilt.mjs",
|