Skip to content

fix(): fix Steam ForegroundServiceDidNotStartInTimeExcception crash#1485

Merged
utkarshdalal merged 1 commit into
utkarshdalal:masterfrom
phobos665:fix/fix-notification-crash
May 29, 2026
Merged

fix(): fix Steam ForegroundServiceDidNotStartInTimeExcception crash#1485
utkarshdalal merged 1 commit into
utkarshdalal:masterfrom
phobos665:fix/fix-notification-crash

Conversation

@phobos665
Copy link
Copy Markdown
Contributor

@phobos665 phobos665 commented May 28, 2026

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

  • 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

Start the foreground notification at the beginning of SteamService.onStartCommand to prevent ForegroundServiceDidNotStartInTimeException when the Steam connection is slow. This fixes the crash and ensures the service meets Android’s 5s start rule.

  • Bug Fixes
    • Start the service notification and call startForeground before any Steam connection logic, and remove the late start to avoid the timeout crash.

Written for commit 2b160ce. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed duplicate foreground service notification initialization, improving service startup reliability.

Review Change Stack

…ting till after the Steam request timeout. Timeouts to steam client can cause the crash as it needs to return before 5s limit
@phobos665 phobos665 requested a review from utkarshdalal as a code owner May 28, 2026 20:50
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

SteamService.kt refactors onStartCommand to initialize the foreground service notification immediately at method start with Android Q+ API guarding (FOREGROUND_SERVICE_TYPE_DATA_SYNC), and removes the duplicate initialization block that previously executed later in the method.

Changes

Foreground Notification Initialization

Layer / File(s) Summary
Early notification initialization with duplicate removal
app/src/main/java/app/gamenative/service/SteamService.kt
Foreground notification setup moves to the start of onStartCommand, guarded by API level check, and marks the notification active. Duplicate initialization at the end of onStartCommand is removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A notification hops early to the start,
No more duplicates to pull apart,
With Android Q guards standing tall,
One clear path handles it all!
Foreground service, clean and bright,

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a ForegroundServiceDidNotStartInTimeException crash in Steam service.
Description check ✅ Passed The description includes all required sections: a clear explanation of the bug, identifies it as a bug fix, and confirms all checklist items including discussion and alignment with project scope.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8744f54 and 2b160ce.

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
// 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.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

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
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: 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>
Suggested change
// Start up the notification early to to avoid ForegroundServiceDidNotStartInTimeException
// Start up the notification early to avoid ForegroundServiceDidNotStartInTimeException

@utkarshdalal utkarshdalal merged commit 263627c into utkarshdalal:master May 29, 2026
3 checks passed
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