Uh oh!
There was an error while loading. Please reload this page.
fix: do not crash at launch when the SDK cannot set the log directory - #473
Merged
Ryanmello07 merged 1 commit intoSep 1, 2026
Merged
Conversation
Sdk.setLogDir is called unguarded in Application.onCreate. Go's SetLogDir returns an error, which gomobile binds into java as `throws Exception`, and kotlin does not enforce checked exceptions -- so the call compiles and then propagates straight out of onCreate: an unhandled crash on every launch on any install where the log directory cannot be written (storage full, quota, EIO). A recoverable logging problem became an unbootable app. Wrap the existing call so the failure is logged and startup continues; glog keeps whatever destination it already had. Logging must never be what breaks a launch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014vN7zh8WeQYCtirhcA3aWw
Uh oh!
There was an error while loading. Please reload this page.
Ryanmello07 pushed a commit
that referenced
this pull request
Sep 1, 2026
MainApplication pointed glog at filesDir itself. Move it to <filesDir>/logs/app via Sdk.setLogDirForProcess, inside the try/catch that #473 added -- the sdk still returns an error when the directory cannot be created, because its os.TempDir() fallback lands on /data/local/tmp, which an app uid cannot write. The retention pass (clearOldLogs) only ever prunes the directory glog is currently pointed at, so moving the root would strand whatever pre-upgrade builds wrote into filesDir: up to four files of up to 16MB each, never pruned again, and no longer reachable through Sdk.getLogDir() -- which is what the feedback screen's share and export buttons read. A user who upgraded and then reported an incident that predated the upgrade would attach none of the logs that recorded it. So migrateLegacyLogFiles moves those files into the new per-process directory BEFORE glog is repointed, which hands the merged set to the same retention pass rather than doubling the storage. It renames rather than copies, never overwrites a file already under the new root (a name collision means an earlier launch already migrated it), and never deletes a log it could not move. Android is single-process, so "app" is the only subdirectory that ever appears; the layout matches iOS, where the app and the network extension would otherwise prune each other's history out of a shared directory. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014vN7zh8WeQYCtirhcA3aWw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One file, +10/−1.
MainApplication.onCreatecallsSdk.setLogDir(path)unguarded. gomobile binds that Go function'serrorreturn as a checked Java exception, and Kotlin does not enforce checked exceptions — so it compiles, and then a log directory that cannot be written (storage full, quota, EIO) propagates straight out ofonCreateas an unhandled crash on every launch.The SDK's own doc comment states the opposite intent: logging must never be what breaks a launch. glog keeps whatever destination it already had, so continuing is safe.
Which function is called is unchanged — this is purely the guard.
Verification
Honestly: this was not compiled locally. The machine it was written on has no JDK and no Android SDK/NDK (
java -versionfails,ANDROID_HOMEunset). It was verified by reading — the caught type is right for a gomobile-bound throwing call, imports are present, brace balance confirmed, and the diff touches exactly one file with no trailing whitespace. This PR's CI run is its first real compile check, which given the size seems a reasonable trade, but worth stating rather than implying otherwise.🤖 Generated with Claude Code