fix(): fix Steam ForegroundServiceDidNotStartInTimeExcception crash#1485
Conversation
…ting till after the Steam request timeout. Timeouts to steam client can cause the crash as it needs to return before 5s limit
📝 WalkthroughWalkthroughSteamService.kt refactors ChangesForeground Notification Initialization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/src/main/java/app/gamenative/service/SteamService.kt`:
- Line 3368: In the SteamService class comment that reads "Start up the
notification early to to avoid ForegroundServiceDidNotStartInTimeException", fix
the typo by changing "to to" to a single "to" so the comment reads "Start up the
notification early to avoid ForegroundServiceDidNotStartInTimeException"; update
the inline comment near the notification startup code in SteamService.kt
accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aee8e296-31fc-4b98-af3e-9f09ec25de36
📒 Files selected for processing (1)
app/src/main/java/app/gamenative/service/SteamService.kt
| override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | ||
| // Notification intents | ||
|
|
||
| // Start up the notification early to to avoid ForegroundServiceDidNotStartInTimeException |
There was a problem hiding this comment.
Fix typo in comment.
The comment has "to to" which should be "to".
✏️ Proposed fix
- // Start up the notification early to to avoid ForegroundServiceDidNotStartInTimeException
+ // Start up the notification early to avoid ForegroundServiceDidNotStartInTimeException📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Start up the notification early to to avoid ForegroundServiceDidNotStartInTimeException | |
| // Start up the notification early to avoid ForegroundServiceDidNotStartInTimeException |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/src/main/java/app/gamenative/service/SteamService.kt` at line 3368, In
the SteamService class comment that reads "Start up the notification early to to
avoid ForegroundServiceDidNotStartInTimeException", fix the typo by changing "to
to" to a single "to" so the comment reads "Start up the notification early to
avoid ForegroundServiceDidNotStartInTimeException"; update the inline comment
near the notification startup code in SteamService.kt accordingly.
There was a problem hiding this comment.
1 issue 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/service/SteamService.kt">
<violation number="1" location="app/src/main/java/app/gamenative/service/SteamService.kt:3368">
P3: Typo in comment: "to to" should be "to".</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | ||
| // Notification intents | ||
|
|
||
| // Start up the notification early to to avoid ForegroundServiceDidNotStartInTimeException |
There was a problem hiding this comment.
P3: Typo in comment: "to to" should be "to".
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/service/SteamService.kt, line 3368:
<comment>Typo in comment: "to to" should be "to".</comment>
<file context>
@@ -3364,7 +3364,16 @@ class SteamService : Service(), IChallengeUrlChanged {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
- // Notification intents
+
+ // Start up the notification early to to avoid ForegroundServiceDidNotStartInTimeException
+ val notification = notificationHelper.createServiceNotification(NotificationHelper.NOTIFICATION_ID_STEAM, "Running...")
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
</file context>
| // Start up the notification early to to avoid ForegroundServiceDidNotStartInTimeException | |
| // Start up the notification early to avoid ForegroundServiceDidNotStartInTimeException |
Description
There's a small edge-case where the Foreground service didn't start in time, causing the app to crash.
In order to fix this, we should start up the notificationService at the top of the onStart rather than wait through all the Steam connection logic, which if timing out, can cause a crash.
Recording
Type of Change
Checklist
#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.CONTRIBUTING.md.Summary by cubic
Start the foreground notification at the beginning of
SteamService.onStartCommandto prevent ForegroundServiceDidNotStartInTimeException when the Steam connection is slow. This fixes the crash and ensures the service meets Android’s 5s start rule.Written for commit 2b160ce. Summary will update on new commits.
Review in cubic
Summary by CodeRabbit