Skip to content

UrlLauncherIOS Safari view controller load crash#4533

Closed
aaravgarg wants to merge 1 commit intomainfrom
fix/ios-crash-safari-view-controller
Closed

UrlLauncherIOS Safari view controller load crash#4533
aaravgarg wants to merge 1 commit intomainfrom
fix/ios-crash-safari-view-controller

Conversation

@aaravgarg
Copy link
Collaborator

Summary

  • Add try-catch around launchUrl with inAppBrowserView mode
  • Fallback to external browser when Safari view controller fails to load
  • Prevents crash when iOS Safari view controller encounters an error loading the URL

Crash Stats

Test plan

  • Verify in-app browser still opens URLs correctly
  • Test fallback to external browser by simulating Safari view controller failure

🤖 Generated with Claude Code

… crash

Catch exceptions from launchUrl with inAppBrowserView mode and fallback
to external browser. Prevents crash when Safari view controller fails
to load the URL.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@aaravgarg aaravgarg requested a review from mdmohsin7 February 1, 2026 23:17
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a crash on iOS when launching URLs in an in-app browser by adding a try-catch block and a fallback mechanism to an external browser. The change is straightforward and effectively prevents the crash. The included comment further improves the robustness of the URL launching logic by handling cases where launchUrl might fail without throwing an exception, which is a valuable enhancement.

Comment on lines +183 to +196
try {
await launchUrl(
uri,
mode: LaunchMode.inAppBrowserView,
);
} catch (e) {
Logger.debug('Failed to launch URL: $e');
// Fallback to external browser if in-app browser fails
try {
await launchUrl(uri, mode: LaunchMode.externalApplication);
} catch (e) {
Logger.debug('Failed to launch URL externally: $e');
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current implementation correctly handles exceptions when launching the URL, which fixes the reported crash. However, launchUrl can also return false on failure without throwing an exception. In that case, the fallback to an external browser would not be triggered, leading to a silent failure.

To make the implementation more robust, we should also handle the false return value from launchUrl. The suggested change refactors the logic to catch both exceptions and false return values from the in-app launch attempt, and then proceeds to the fallback in either case.

    try {
      if (!await launchUrl(uri, mode: LaunchMode.inAppBrowserView)) {
        throw Exception('launchUrl returned false');
      }
    } catch (e) {
      Logger.debug('Failed to launch URL in-app, falling back: $e');

      try {
        if (!await launchUrl(uri, mode: LaunchMode.externalApplication)) {
          Logger.debug('Failed to launch URL externally, launchUrl returned false.');
        }
      } catch (e2) {
        Logger.debug('Failed to launch URL externally: $e2');
      }
    }

@mdmohsin7
Copy link
Member

closed in #4628

@mdmohsin7 mdmohsin7 closed this Feb 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Hey @aaravgarg 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our roadmap and vision

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community! 💜

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