Skip to content

Fingerprint translation-stack crashes in game_exited - #2374

Closed
utkarshdalal wants to merge 2 commits into
masterfrom
crash-fingerprint
Closed

utkarshdalal wants to merge 2 commits into
masterfrom
crash-fingerprint

Conversation

@utkarshdalal

@utkarshdalal utkarshdalal commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Description

Adds a compact crash fingerprint to game_exited so the server can cluster crashes per game and component version.

Capture. In a normal launch nothing from the guest is kept: WINEDEBUG=-all, DXVK_LOG_LEVEL=none, MESA_DEBUG=silent, and the always-registered debug callback in setupXEnvironment reads guest stdout/stderr line by line but only writes them to a file on debug runs or with Wine/Box64 logging enabled. That callback now also appends each line to GuestOutputTail, an in-memory ring capped at 256 KB (lines capped at 4 KB). There is no new thread, file or log during play, just one bounded append in a callback that already runs for every line.

Fingerprint. CrashFingerprint.extract(tail, exitReason, componentVersions) is pure. It matches:

  • wine: wine: Unhandled ..., winedbg Unhandled exception: ... in NN-bit code, Exception code, the top 3 Backtrace frames as module!symbol+0xoff or module+0xoff, Call from ... to unimplemented function, err:module:import_dll / other err:module failures, and wineserver loss
  • FEX: unknown or unhandled instruction (with the bytes), unhandled syscall, signals
  • Box64: Unimplemented Opcode, Unsupported Syscall, dynarec errors
  • Mesa/Turnip: Assertion ... failed, VK_ERROR_DEVICE_LOST / GPU hang, MESA: error
  • DXVK: err: and DxvkError
  • vkd3d-proton: err:d3d12_* / err:vkd3d*

The highest-priority match wins. Instruction faults beat asserts, which beat device loss, then exceptions, unimplemented functions, load failures, syscalls and plain err: lines. A crash in a module that is not a known wine, DXVK, vkd3d, FEX or Mesa module is attributed to game.

Shape: {component, kind, code, module, frames[≤3], sample[≤5 lines ≤200 chars], hash, versions}. Hex runs of 6 or more digits become 0x…, and wine/box64 thread and pid prefixes are stripped. hash is the first 16 hex of sha256(component|kind|code|module|frames). The serialized size is capped at 2 KB. It returns null when nothing matched and the exit was not guest_terminated. A guest_terminated exit with no match gives component=none, kind=other.

Wiring. game_exited and recordRun are sent from the same place and thread as on master. In exit(), the props get crash_fingerprint (map) and crash_fingerprint_hash, extracted from the in-memory tail. Extraction runs on Dispatchers.IO and exit() waits for it for at most 200 ms; on timeout or any failure it adds nothing (catch-all, logged with Timber). For a guest_terminated exit the tail is complete by then; a user-initiated exit has nothing to find. versions carries wine, emulator, fexcore, box64, graphics driver + version, and dxwrapper + version from the container. The fingerprint is also stored in .gamenative/runs/*.json, so the next launch can read it. It is pipeline diagnostics and follows the same gating as game_exited, nothing more.

Not built locally; CI compiles and runs CrashFingerprintTest.

Recording

Not applicable (telemetry only).

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Summary by cubic

Adds a compact crash fingerprint to game_exited so crashes can be clustered per game and component version.

  • Keeps the last 256 KB of guest stdout/stderr in a bounded in-memory ring appended by the existing debug callback; no new thread, file, or log during play.
  • A pure matcher detects Wine, FEX, Box64, Mesa/Turnip, DXVK, and vkd3d-proton crash patterns and produces component, kind, code, module, up to 3 backtrace frames, and a 5-line sample capped at 200 chars each.
  • Thread IDs, PIDs, and long hex runs are normalized so identical crashes hash the same.
  • The fingerprint is extracted in exit() with a 200 ms timeout, sent with game_exited from the same place as before, and stored in .gamenative/runs/*.json for the next launch.
  • Normal exits yield no fingerprint; a guest_terminated exit without a match yields component=none, kind=other.

Written for commit 599dd6f. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • New Features
    • Session reports can now include a structured crash fingerprint for recognized failures, with details such as the affected component, error type, and relevant software versions.
    • Fingerprints include a concise log sample and a stable identifier to help distinguish failure patterns. For clean or unrecognized logs, reports omit the fingerprint unless the guest process has terminated.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The change retains guest debug output, classifies recognized failures into bounded crash fingerprints, and adds fingerprint properties to exit analytics. Fingerprint computation runs asynchronously and contributes no properties if it fails or exceeds the wait limit.

Changes: Guest crash reporting

Layer / File(s) Summary
Retain guest output
app/src/main/java/app/gamenative/utils/CrashFingerprint.kt, app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
GuestOutputTail retains guest output within a 256 KB limit and supports reset and snapshot operations. XServerScreen resets the buffer and appends each debug line while preserving optional file logging.
Classify guest failures
app/src/main/java/app/gamenative/utils/CrashFingerprint.kt, app/src/test/java/app/gamenative/utils/CrashFingerprintTest.kt
CrashFingerprint matches supported failure patterns, selects a prioritized match, and produces normalized, bounded fingerprint data. Tests cover failure classifications, hashes, samples, serialization limits, and tail parsing.
Add fingerprints to exit reports
app/src/main/java/app/gamenative/utils/SessionReport.kt, app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
SessionReport collects component versions and returns fingerprint properties when extraction succeeds. XServerScreen computes these properties asynchronously and adds none when computation fails or times out.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant XServerScreen
  participant GuestOutputTail
  participant SessionReport
  participant CrashFingerprint
  XServerScreen->>GuestOutputTail: Append guest debug lines
  XServerScreen->>SessionReport: Request fingerprint properties
  SessionReport->>GuestOutputTail: Read output snapshot
  SessionReport->>CrashFingerprint: Extract fingerprint using reason and versions
  CrashFingerprint-->>SessionReport: Return fingerprint or no match
  SessionReport-->>XServerScreen: Return properties
Loading
Merge Risk: Moderate · up to 599dd

Resolve sensitive guest-text export before merging. Crash reports can also misidentify successful exits or attribute incomplete, stale or incorrectly versioned diagnostics; extraction and serialization need tighter bounds.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 issues found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/src/main/java/app/gamenative/utils/CrashFingerprint.kt">

<violation number="1" location="app/src/main/java/app/gamenative/utils/CrashFingerprint.kt:161">
P2: Matched patterns produce a fingerprint even on a clean exit, because the exit reason is only checked when nothing matches. Consider gating the matched-hit path on an abnormal exit, or confirm that benign `err:` lines on normal exits are intended to be reported.</violation>

<violation number="2" location="app/src/main/java/app/gamenative/utils/CrashFingerprint.kt:204">
P3: The size cap is not guaranteed. After the sample and versions fallbacks, `fp` can still exceed MAX_SERIALIZED_CHARS when escaped frames or module/code fields are large. Enforce the cap on the final JSON, for example by truncating frames or failing closed.</violation>

<violation number="3" location="app/src/main/java/app/gamenative/utils/CrashFingerprint.kt:220">
P2: This condition classifies every matching generic `Unhandled instruction` line as FEX, so it overrides the Wine exception detector and misattributes crashes. Require an explicit FEX marker before returning this hit.</violation>

<violation number="4" location="app/src/main/java/app/gamenative/utils/CrashFingerprint.kt:248">
P2: The WINE_STUB branch hard-codes the component to "wine", so stubs from d3d11/dxgi, vkd3d, or FEX DLLs are misattributed. Use `componentForModule(dll)`, which already maps these modules, so the clustering matches the rest of the extractor.</violation>

<violation number="5" location="app/src/main/java/app/gamenative/utils/CrashFingerprint.kt:275">
P2: This branch discards the vkd3d error message and uses only the emitter name as `code`, collapsing distinct vkd3d failures into one fingerprint. Use group 2, with group 1 only as an empty-message fallback.</violation>
</file>

<file name="app/src/main/java/app/gamenative/utils/SessionReport.kt">

<violation number="1" location="app/src/main/java/app/gamenative/utils/SessionReport.kt:170">
P3: This new function has no test. Add a case that covers the version-map assembly, including the `dxwrapper_version` selection, and the empty-tail `emptyMap()` path.</violation>

<violation number="2" location="app/src/main/java/app/gamenative/utils/SessionReport.kt:180">
P2: `dxwrapper_version` always reads the DXVK `version` key. For `vkd3d` containers the vkd3d-proton version (`vkd3dVersion`) is never reported, and for `wined3d` a DXVK version is reported even though DXVK is not in use. Select the key by wrapper, and drop the version when the wrapper is neither `dxvk` nor `vkd3d`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

}

VKD3D_ERR.find(line)?.let { m ->
return Hit(40, i, "vkd3d", "other", m.groupValues[1].lowercase())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This branch discards the vkd3d error message and uses only the emitter name as code, collapsing distinct vkd3d failures into one fingerprint. Use group 2, with group 1 only as an empty-message fallback.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/utils/CrashFingerprint.kt, line 275:

<comment>This branch discards the vkd3d error message and uses only the emitter name as `code`, collapsing distinct vkd3d failures into one fingerprint. Use group 2, with group 1 only as an empty-message fallback.</comment>

<file context>
@@ -0,0 +1,401 @@
+        }
+
+        VKD3D_ERR.find(line)?.let { m ->
+            return Hit(40, i, "vkd3d", "other", m.groupValues[1].lowercase())
+        }
+        DXVK_ERROR.find(line)?.let { m -> return Hit(40, i, "dxvk", "other", normalizeCode(m.groupValues[1].ifEmpty { "DxvkError" })) }
</file context>

}
if (!lower.contains("box64")) {
FEX_INSTRUCTION.find(line)?.let { m ->
if (lower.contains("fex") || lower.contains("instruction")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This condition classifies every matching generic Unhandled instruction line as FEX, so it overrides the Wine exception detector and misattributes crashes. Require an explicit FEX marker before returning this hit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/utils/CrashFingerprint.kt, line 220:

<comment>This condition classifies every matching generic `Unhandled instruction` line as FEX, so it overrides the Wine exception detector and misattributes crashes. Require an explicit FEX marker before returning this hit.</comment>

<file context>
@@ -0,0 +1,401 @@
+        }
+        if (!lower.contains("box64")) {
+            FEX_INSTRUCTION.find(line)?.let { m ->
+                if (lower.contains("fex") || lower.contains("instruction")) {
+                    val rest = m.groupValues[1]
+                    val code = INSTRUCTION_BYTES.find(rest)?.let { bytes(it.value) }?.ifEmpty { null } ?: normalizeCode(rest)
</file context>

"graphics_driver_version" to KeyValueSet(container.getGraphicsDriverConfig()).get("version")
.ifEmpty { container.getGraphicsDriverVersion().orEmpty() },
"dxwrapper" to container.getDXWrapper().orEmpty(),
"dxwrapper_version" to DXVKHelper.parseConfig(container.getDXWrapperConfig()).get("version"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: dxwrapper_version always reads the DXVK version key. For vkd3d containers the vkd3d-proton version (vkd3dVersion) is never reported, and for wined3d a DXVK version is reported even though DXVK is not in use. Select the key by wrapper, and drop the version when the wrapper is neither dxvk nor vkd3d.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/utils/SessionReport.kt, line 180:

<comment>`dxwrapper_version` always reads the DXVK `version` key. For `vkd3d` containers the vkd3d-proton version (`vkd3dVersion`) is never reported, and for `wined3d` a DXVK version is reported even though DXVK is not in use. Select the key by wrapper, and drop the version when the wrapper is neither `dxvk` nor `vkd3d`.</comment>

<file context>
@@ -165,6 +167,26 @@ object SessionReport {
+            "graphics_driver_version" to KeyValueSet(container.getGraphicsDriverConfig()).get("version")
+                .ifEmpty { container.getGraphicsDriverVersion().orEmpty() },
+            "dxwrapper" to container.getDXWrapper().orEmpty(),
+            "dxwrapper_version" to DXVKHelper.parseConfig(container.getDXWrapperConfig()).get("version"),
+        ).filterValues { it.isNotEmpty() }
+        CrashFingerprint.extract(GuestOutputTail.snapshot(), reason, versions)
</file context>

for (i in lines.indices) matchLine(lines, i)?.let(hits::add)

val best = hits.maxWithOrNull(compareBy<Hit>({ it.priority }, { it.index }))
if (best == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Matched patterns produce a fingerprint even on a clean exit, because the exit reason is only checked when nothing matches. Consider gating the matched-hit path on an abnormal exit, or confirm that benign err: lines on normal exits are intended to be reported.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/utils/CrashFingerprint.kt, line 161:

<comment>Matched patterns produce a fingerprint even on a clean exit, because the exit reason is only checked when nothing matches. Consider gating the matched-hit path on an abnormal exit, or confirm that benign `err:` lines on normal exits are intended to be reported.</comment>

<file context>
@@ -0,0 +1,401 @@
+        for (i in lines.indices) matchLine(lines, i)?.let(hits::add)
+
+        val best = hits.maxWithOrNull(compareBy<Hit>({ it.priority }, { it.index }))
+        if (best == null) {
+            if (exitReason == null || exitReason !in ABNORMAL_EXITS) return null
+            return build("none", "other", exitReason, "", emptyList(), emptyList(), componentVersions)
</file context>


WINE_STUB.find(line)?.let { m ->
val (dll, fn) = splitDllFunction(m.groupValues[1])
return Hit(75, i, "wine", "unimplemented", "$dll.$fn", dll)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The WINE_STUB branch hard-codes the component to "wine", so stubs from d3d11/dxgi, vkd3d, or FEX DLLs are misattributed. Use componentForModule(dll), which already maps these modules, so the clustering matches the rest of the extractor.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/utils/CrashFingerprint.kt, line 248:

<comment>The WINE_STUB branch hard-codes the component to "wine", so stubs from d3d11/dxgi, vkd3d, or FEX DLLs are misattributed. Use `componentForModule(dll)`, which already maps these modules, so the clustering matches the rest of the extractor.</comment>

<file context>
@@ -0,0 +1,401 @@
+
+        WINE_STUB.find(line)?.let { m ->
+            val (dll, fn) = splitDllFunction(m.groupValues[1])
+            return Hit(75, i, "wine", "unimplemented", "$dll.$fn", dll)
+        }
+
</file context>
Suggested change
return Hit(75, i, "wine", "unimplemented", "$dll.$fn", dll)
return Hit(75, i, componentForModule(dll), "unimplemented", "$dll.$fn", dll)


private const val MAX_RUN_FILES = 30

fun crashFingerprintProperties(container: Container, reason: String): Map<String, Any> = try {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This new function has no test. Add a case that covers the version-map assembly, including the dxwrapper_version selection, and the empty-tail emptyMap() path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/utils/SessionReport.kt, line 170:

<comment>This new function has no test. Add a case that covers the version-map assembly, including the `dxwrapper_version` selection, and the empty-tail `emptyMap()` path.</comment>

<file context>
@@ -165,6 +167,26 @@ object SessionReport {
 
     private const val MAX_RUN_FILES = 30
 
+    fun crashFingerprintProperties(container: Container, reason: String): Map<String, Any> = try {
+        val versions = linkedMapOf(
+            "wine" to container.getWineVersion().orEmpty(),
</file context>

while (fp.toJson().length > MAX_SERIALIZED_CHARS && fp.sample.isNotEmpty()) {
fp = fp.copy(sample = fp.sample.dropLast(1))
}
if (fp.toJson().length > MAX_SERIALIZED_CHARS) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The size cap is not guaranteed. After the sample and versions fallbacks, fp can still exceed MAX_SERIALIZED_CHARS when escaped frames or module/code fields are large. Enforce the cap on the final JSON, for example by truncating frames or failing closed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/utils/CrashFingerprint.kt, line 204:

<comment>The size cap is not guaranteed. After the sample and versions fallbacks, `fp` can still exceed MAX_SERIALIZED_CHARS when escaped frames or module/code fields are large. Enforce the cap on the final JSON, for example by truncating frames or failing closed.</comment>

<file context>
@@ -0,0 +1,401 @@
+        while (fp.toJson().length > MAX_SERIALIZED_CHARS && fp.sample.isNotEmpty()) {
+            fp = fp.copy(sample = fp.sample.dropLast(1))
+        }
+        if (fp.toJson().length > MAX_SERIALIZED_CHARS) {
+            fp = fp.copy(versions = fp.versions.mapValues { it.value.take(48) }.entries.take(8).associate { it.key.take(32) to it.value })
+        }
</file context>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 existing issues remain and 3 new issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt">

<violation number="1" location="app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt:4456">
P2: Resetting one global tail does not isolate sessions because previous ProcessHelper readers can still call the newly registered callback after reset. Associate the tail with a session and ignore late callbacks from prior launches.</violation>

<violation number="2" location="app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt:5487">
P2: The fingerprint is extracted before ProcessHelper’s output-reader threads are guaranteed to drain, so a crash’s final diagnostic lines can be missed and `game_exited` can omit or misclassify the fingerprint. Add a termination/output-drain barrier before snapshotting the tail.</violation>

<violation number="3" location="app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt:5488">
P2: `runBlocking` makes the IO timeout a synchronous wait on the exit caller, blocking the UI thread for up to 200 ms on quick-menu, force-close, or activity teardown. Make exit’s fingerprint/telemetry path suspend or dispatch the exit work without blocking the main thread.</violation>
</file>

Requires human review: Auto-approval blocked because this review re-detected 3 unresolved issues already reported by Cubic.

View guided diff | Turn on auto-fix | Re-trigger cubic

if (debugRun) DebugReportUtils.startLogcatCapture(context, appId)
}

GuestOutputTail.reset()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Resetting one global tail does not isolate sessions because previous ProcessHelper readers can still call the newly registered callback after reset. Associate the tail with a session and ignore late callbacks from prior launches.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt, line 4456:

<comment>Resetting one global tail does not isolate sessions because previous ProcessHelper readers can still call the newly registered callback after reset. Associate the tail with a session and ignore late callbacks from prior launches.</comment>

<file context>
@@ -4451,7 +4453,9 @@ private fun setupXEnvironment(
         if (debugRun) DebugReportUtils.startLogcatCapture(context, appId)
     }
 
+    GuestOutputTail.reset()
     ProcessHelper.addDebugCallback { line ->
+        GuestOutputTail.append(line)
</file context>

}.getOrElse { emptyMap() }
}.getOrElse { emptyMap() } + runCatching {
val fingerprint = CoroutineScope(Dispatchers.IO).async { SessionReport.crashFingerprintProperties(container, reason) }
runBlocking { withTimeoutOrNull(200) { fingerprint.await() } }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: runBlocking makes the IO timeout a synchronous wait on the exit caller, blocking the UI thread for up to 200 ms on quick-menu, force-close, or activity teardown. Make exit’s fingerprint/telemetry path suspend or dispatch the exit work without blocking the main thread.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt, line 5488:

<comment>`runBlocking` makes the IO timeout a synchronous wait on the exit caller, blocking the UI thread for up to 200 ms on quick-menu, force-close, or activity teardown. Make exit’s fingerprint/telemetry path suspend or dispatch the exit work without blocking the main thread.</comment>

<file context>
@@ -5479,7 +5483,10 @@ private fun exit(
-    }.getOrElse { emptyMap() }
+    }.getOrElse { emptyMap() } + runCatching {
+        val fingerprint = CoroutineScope(Dispatchers.IO).async { SessionReport.crashFingerprintProperties(container, reason) }
+        runBlocking { withTimeoutOrNull(200) { fingerprint.await() } }
+    }.getOrNull().orEmpty()
     PostHog.capture(
</file context>

GameCompatibilityService.badgeProperties(ContainerUtils.resolveGameName(appId))
}.getOrElse { emptyMap() }
}.getOrElse { emptyMap() } + runCatching {
val fingerprint = CoroutineScope(Dispatchers.IO).async { SessionReport.crashFingerprintProperties(container, reason) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The fingerprint is extracted before ProcessHelper’s output-reader threads are guaranteed to drain, so a crash’s final diagnostic lines can be missed and game_exited can omit or misclassify the fingerprint. Add a termination/output-drain barrier before snapshotting the tail.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt, line 5487:

<comment>The fingerprint is extracted before ProcessHelper’s output-reader threads are guaranteed to drain, so a crash’s final diagnostic lines can be missed and `game_exited` can omit or misclassify the fingerprint. Add a termination/output-drain barrier before snapshotting the tail.</comment>

<file context>
@@ -5479,7 +5483,10 @@ private fun exit(
         GameCompatibilityService.badgeProperties(ContainerUtils.resolveGameName(appId))
-    }.getOrElse { emptyMap() }
+    }.getOrElse { emptyMap() } + runCatching {
+        val fingerprint = CoroutineScope(Dispatchers.IO).async { SessionReport.crashFingerprintProperties(container, reason) }
+        runBlocking { withTimeoutOrNull(200) { fingerprint.await() } }
+    }.getOrNull().orEmpty()
</file context>

@utkarshdalal

Copy link
Copy Markdown
Owner Author

Folded into #2363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant