Skip to content

Set EVSHIM_BASE_PATH in the host process so gamepad shm is not hardcoded to app.gamenative - #1818

Open
faux123 wants to merge 1 commit into
utkarshdalal:masterfrom
faux123:fix/evshim-host-shm-basepath
Open

Set EVSHIM_BASE_PATH in the host process so gamepad shm is not hardcoded to app.gamenative#1818
faux123 wants to merge 1 commit into
utkarshdalal:masterfrom
faux123:fix/evshim-host-shm-basepath

Conversation

@faux123

@faux123 faux123 commented Aug 15, 2026

Copy link
Copy Markdown

Problem

On any build whose applicationId is not exactly app.gamenative, no controller input reaches any game. This includes this repo's own release-gold flavor (app.gamenative.gold) and any fork/rename.

Root cause

libevshim.so sets up its gamepad shared memory in a C constructor (initialize_all_pads, __attribute__((constructor))) that runs at library load. build_gamepad_dir() derives the directory from getenv("EVSHIM_BASE_PATH"), otherwise falling back to a hardcoded "/data/data/app.gamenative/files".

EVSHIM_BASE_PATH is exported into the guest (wine) process env in BionicProgramLauncherComponent, but it is not set in the host process that loads libevshim and calls notifyStateChanged. On the stock package the host's getenv is unset so it uses the hardcoded fallback, which happens to be correct. On a renamed package that fallback points at the wrong app's data dir, which the app cannot create or mmap, so:

  • host shm[i] is null;
  • logcat spams evshim: notifyStateChanged missing shm for slot=0;
  • Java (WinHandler) writes pad state to getFilesDir()/gamepad_shm (correct dir) while native reads the stock dir, so they never meet and no game sees the pad.

Stock app.gamenative is not affected. The release-gold build type (applicationIdSuffix = ".gold") is.

Fix

Set EVSHIM_BASE_PATH = filesDir in PluviaApp.onCreate, before any evshim load. Package-agnostic: on stock it equals the hardcoded fallback (no behavior change); on renamed/gold builds the host now uses the correct data dir.

Verification

On a renamed build (applicationId app.gamenative.mali, RK3588 / Mali-G610): before, continuous "missing shm for slot=0" and a dead controller; after, the host mmaps all player slots (java P0-P3 mmap'd), zero "missing shm" errors, and controller input works in-game.

(Issues are disabled on the repo, so filing this as a PR with the full report.)


Summary by cubic

Ensure host process sets the gamepad SHM base path so controllers work on renamed builds. Previously the host defaulted to /data/data/app.gamenative/files when EVSHIM_BASE_PATH was unset, breaking input on builds whose applicationId isn’t app.gamenative; now it sets the env var to filesDir at startup with no behavior change on stock.

Review notes

  • Sets EVSHIM_BASE_PATH via android.system.Os.setenv(filesDir.absolutePath, overwrite=true) in PluviaApp.onCreate before any evshim load.
  • Host-only change; the guest (Wine) env is unchanged.
  • On stock app.gamenative this matches the fallback path; failures only log a warning.

Written for commit 72753e4. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved application startup reliability by configuring required runtime storage before native components load.
    • Startup now continues gracefully if the runtime path cannot be configured.

…ardcoded to app.gamenative

libevshim.so builds its gamepad shared-memory directory in a C constructor
(initialize_all_pads, __attribute__((constructor))) that runs at library load,
from getenv("EVSHIM_BASE_PATH") and otherwise a hardcoded
"/data/data/app.gamenative/files". EVSHIM_BASE_PATH is exported to the guest
(wine) process but not to the host process that loads libevshim and calls
notifyStateChanged. On any build whose applicationId is not exactly
"app.gamenative" -- the release-gold flavor (app.gamenative.gold) or any
fork/rename -- the host's shm setup targets the stock app's data dir, which it
cannot create or mmap, so host shm[i] is null, notifyStateChanged logs
"missing shm for slot=N", and no controller input reaches any game.

Set EVSHIM_BASE_PATH = filesDir in PluviaApp.onCreate, before any evshim load.
Package-agnostic: on the stock package it equals the hardcoded fallback, so
there is no behavior change; on renamed/gold builds the host now uses the
correct data dir. Verified on a renamed build (applicationId app.gamenative.mali,
RK3588/Mali-G610): before, continuous "missing shm for slot=0" and no pad input;
after, the host mmaps all player slots and controller input works in-game.
@faux123
faux123 requested a review from utkarshdalal as a code owner August 15, 2026 03:49
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a3f33a70-48f5-4548-bd7f-c8fc5798a0c3

📥 Commits

Reviewing files that changed from the base of the PR and between b0424df and 72753e4.

📒 Files selected for processing (1)
  • app/src/main/java/app/gamenative/PluviaApp.kt

📝 Walkthrough

Walkthrough

PluviaApp.onCreate() now sets EVSHIM_BASE_PATH to the application filesDir before native libraries load. Environment-setting failures are caught and logged.

Changes

EVSHIM path setup

Layer / File(s) Summary
Startup path configuration
app/src/main/java/app/gamenative/PluviaApp.kt
onCreate() sets EVSHIM_BASE_PATH from filesDir.absolutePath before preloading system libraries. Failures are logged as warnings without stopping initialization.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 72753

This is a localized initialization change that sets the shared-memory base path for renamed builds; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

Suggested reviewers: utkarshdalal

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change and its purpose: setting EVSHIM_BASE_PATH to fix shared-memory gamepad support.
Description check ✅ Passed The description clearly explains the problem, root cause, fix, affected builds, and verification results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (redundant_comments). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

faux123 added a commit to faux123/GameNative-Mali that referenced this pull request Aug 15, 2026
…VK-Sarek ceiling, software BCn, DX12=no, wrapper/box64 baked-in, UE4->D3D11 default, evshim controller fix + PR utkarshdalal#1818)

Corrects the PRD premise: rebuilding the wrapper does not unlock modern
DXVK on Mali; the missing core Vulkan features are silicon limits, so the
DXVK 1.x Sarek line is the ceiling.

Claude-Session: https://claude.ai/code/session_01JZcRjgSzRJdaCCWKnBk2mE

@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.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


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

<violation number="1" location="app/src/main/java/app/gamenative/PluviaApp.kt:59">
P3: The added comment states that EVSHIM_BASE_PATH is set for the guest (wine) process in BionicProgramLauncherComponent, but the codebase never sets this variable for the guest (only EVSHIM_WINE and EVSHIM_SHM_NAME are there). The fix relies on the guest inheriting the host process's environment, not on BionicProgramLauncherComponent. Reword the comment so it doesn't assert a mechanism that isn't in the code.</violation>

<violation number="2" location="app/src/main/java/app/gamenative/PluviaApp.kt:68">
P1: On renamed builds, the guest still resolves the shared-memory directory to the hardcoded `app.gamenative` path. This host-only setting makes the host and Java sides use `filesDir` while Wine's evshim uses the fallback, so controller input remains disconnected; add the same `EVSHIM_BASE_PATH` value to the explicit guest environment before launching Wine.</violation>
</file>

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

Re-trigger cubic

// resolves to the same path the hardcoded fallback uses, so there is no
// behavior change there.
try {
android.system.Os.setenv("EVSHIM_BASE_PATH", filesDir.absolutePath, true)

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.

P1: On renamed builds, the guest still resolves the shared-memory directory to the hardcoded app.gamenative path. This host-only setting makes the host and Java sides use filesDir while Wine's evshim uses the fallback, so controller input remains disconnected; add the same EVSHIM_BASE_PATH value to the explicit guest environment before launching Wine.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/PluviaApp.kt, line 68:

<comment>On renamed builds, the guest still resolves the shared-memory directory to the hardcoded `app.gamenative` path. This host-only setting makes the host and Java sides use `filesDir` while Wine's evshim uses the fallback, so controller input remains disconnected; add the same `EVSHIM_BASE_PATH` value to the explicit guest environment before launching Wine.</comment>

<file context>
@@ -53,6 +53,23 @@ class PluviaApp : SplitCompatApplication() {
+        // resolves to the same path the hardcoded fallback uses, so there is no
+        // behavior change there.
+        try {
+            android.system.Os.setenv("EVSHIM_BASE_PATH", filesDir.absolutePath, true)
+        } catch (e: Exception) {
+            android.util.Log.w("PluviaApp", "Failed to set EVSHIM_BASE_PATH for host process", e)
</file context>

Comment on lines +59 to +62
// That env var is set for the guest (wine) process but not for THIS host
// process, so on any build whose applicationId is not exactly
// "app.gamenative" (e.g. the release-gold flavor -> app.gamenative.gold, or
// a fork/rename) the host builds the pad shm under the wrong app's data

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 added comment states that EVSHIM_BASE_PATH is set for the guest (wine) process in BionicProgramLauncherComponent, but the codebase never sets this variable for the guest (only EVSHIM_WINE and EVSHIM_SHM_NAME are there). The fix relies on the guest inheriting the host process's environment, not on BionicProgramLauncherComponent. Reword the comment so it doesn't assert a mechanism that isn't in the code.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/PluviaApp.kt, line 59:

<comment>The added comment states that EVSHIM_BASE_PATH is set for the guest (wine) process in BionicProgramLauncherComponent, but the codebase never sets this variable for the guest (only EVSHIM_WINE and EVSHIM_SHM_NAME are there). The fix relies on the guest inheriting the host process's environment, not on BionicProgramLauncherComponent. Reword the comment so it doesn't assert a mechanism that isn't in the code.</comment>

<file context>
@@ -53,6 +53,23 @@ class PluviaApp : SplitCompatApplication() {
+        // libevshim.so sets up its gamepad shared memory in a C constructor at
+        // library load, deriving the directory from getenv("EVSHIM_BASE_PATH") and
+        // otherwise falling back to a hardcoded "/data/data/app.gamenative/files".
+        // That env var is set for the guest (wine) process but not for THIS host
+        // process, so on any build whose applicationId is not exactly
+        // "app.gamenative" (e.g. the release-gold flavor -> app.gamenative.gold, or
</file context>
Suggested change
// That env var is set for the guest (wine) process but not for THIS host
// process, so on any build whose applicationId is not exactly
// "app.gamenative" (e.g. the release-gold flavor -> app.gamenative.gold, or
// a fork/rename) the host builds the pad shm under the wrong app's data
// libevshim.so never sets this var for the guest; the guest (wine)
// process is forked from this host and inherits its environment, but the
// host process that loads libevshim and calls notifyStateChanged has no
// EVSHIM_BASE_PATH of its own, so it falls back to the hardcoded path.

@utkarshdalal

Copy link
Copy Markdown
Owner

is this not included in #1810 ?

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.

2 participants