-
-
Notifications
You must be signed in to change notification settings - Fork 268
Fix: Stuck loading screen during Mono/XAudio install #1395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
cf356a7
c01701e
595a124
f51141e
395ef7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quite a few AI comments here. Would you mind addressing these @Catpotatos and I'll take another look at this afterwards?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @phobos665 , i believe it's all been addressed now, i added a seperate method with pipe drain for the callers that explicitly mention includeStderr=false to address the bot comment. All others that don't mention it for booting/launching, will go through the merged pipe.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -709,48 +709,9 @@ public String execShellCommand(String command, boolean includeStderr) { | |
| FileUtils.chmod(box64File, 0755); | ||
| } | ||
|
|
||
| // Execute the command and capture its output. | ||
| // | ||
| // IMPORTANT: stderr MUST be drained concurrently with stdout, even when | ||
| // includeStderr=false. Wine spits out a flood of fixme:/err: lines on | ||
| // stderr; if we don't read it, the kernel's pipe buffer (~64 KB) fills, | ||
| // wine's next write(stderr,...) blocks, and the whole subprocess hangs | ||
| // forever -- which then deadlocks our stdout read too. SteamTokenLogin | ||
| // calls this with includeStderr=false, so this used to hang on boot. | ||
| try { | ||
| Log.d("BionicProgramLauncherComponent", "Shell command is " + finalCommand); | ||
| java.lang.Process process = Runtime.getRuntime().exec(finalCommand, envVars.toStringArray(), workingDir != null ? workingDir : imageFs.getRootDir()); | ||
| BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); | ||
| BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); | ||
|
|
||
| final StringBuilder stderrBuf = new StringBuilder(); | ||
| Thread stderrPump = new Thread(() -> { | ||
| try { | ||
| String l; | ||
| while ((l = errorReader.readLine()) != null) { | ||
| if (includeStderr) stderrBuf.append(l).append('\n'); | ||
| // else: discard, but we MUST still consume the stream | ||
| } | ||
| } catch (IOException ignored) { | ||
| // Subprocess closed stderr; fine. | ||
| } | ||
| }, "execShellCommand-stderr-pump"); | ||
| stderrPump.setDaemon(true); | ||
| stderrPump.start(); | ||
|
|
||
| String line; | ||
| while ((line = reader.readLine()) != null) { | ||
| output.append(line).append("\n"); | ||
| } | ||
| process.waitFor(); | ||
| stderrPump.join(); | ||
| if (includeStderr) output.append(stderrBuf); | ||
| } catch (Exception e) { | ||
| output.append("Error: ").append(e.getMessage()); | ||
| } | ||
|
|
||
| // Format output: trim trailing whitespace/newlines | ||
| return output.toString().trim(); | ||
| Log.d("BionicProgramLauncherComponent", "Shell command is " + finalCommand); | ||
| return ProcessHelper.execWithOutput(finalCommand, envVars.toStringArray(), | ||
| workingDir != null ? workingDir : imageFs.getRootDir(), includeStderr); | ||
|
Comment on lines
+505
to
+507
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't log the raw shell command.
Suggested fix- Log.d("BionicProgramLauncherComponent", "Shell command is " + finalCommand);
+ Log.d("BionicProgramLauncherComponent", "Executing shell command");
return ProcessHelper.execWithOutput(finalCommand, envVars.toStringArray(),
workingDir != null ? workingDir : imageFs.getRootDir(), includeStderr);🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| public void restartWineServer() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In Java/Android, when Runtime.exec(String[], String[], File) is called with envp = null, does the child inherit the current process environment? How should ProcessBuilder be configured to preserve that behavior?💡 Result:
Yes, when Runtime.exec(String[], String[], File) is called with envp = null, the child process inherits the environment settings of the current Java process [1][2][3]. To achieve this same behavior using ProcessBuilder, you do not need to perform any special configuration. By default, a ProcessBuilder instance initializes its environment map as a copy of the current process's environment [4][5]. When you call start on a ProcessBuilder, the subprocess uses this map as its environment [5]. If you have modified the environment map (e.g., by adding or removing variables) and wish to revert to the default behavior of inheriting the current process's environment, you would need to manually clear the map and repopulate it with the current process's environment variables, typically retrieved via System.getenv [4][5]. However, for a newly created ProcessBuilder, inheritance is the default state [4][5].
Citations:
🏁 Script executed:
Repository: utkarshdalal/GameNative
Length of output: 124
🏁 Script executed:
Repository: utkarshdalal/GameNative
Length of output: 1366
Preserve inherited environment when
envpis null.env.clear()at line 125 runs before the null check, soexecWithOutput(..., null, ...)now starts children with an empty environment instead of inheriting the current one likeRuntime.exec(..., null, ...)does.Suggested fix
ProcessBuilder pb = new ProcessBuilder(splitCommand(command)); Map<String, String> env = pb.environment(); - env.clear(); if (envp != null) { + env.clear(); for (String kv : envp) { int eq = kv.indexOf('='); if (eq > 0) env.put(kv.substring(0, eq), kv.substring(eq + 1)); } }🤖 Prompt for AI Agents