Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 29, 2025

Problem

The app was crashing on Android when users entered non-URL text (like plain text or relative paths) due to an uncaught rust::cxxbridge1::Error: relative URL without a base exception. The crash occurred because C++ exception handling was disabled in the Android CMake configuration, preventing the existing try-catch block in content.cpp:382 from properly catching Rust exceptions.

Root Cause

The issue was in the Android CMake configuration in cmake/TransmuteCommon.cmake:

  1. The -Wl,--no-eh-frame-hdr linker flag disabled exception frame header generation
  2. This prevented C++ try-catch blocks from working properly with cxx bridge exceptions
  3. When crates::parseURL() threw an exception for invalid URLs, it couldn't be caught
  4. This caused the app to terminate with SIGABRT instead of gracefully handling the error

Solution

Fixed the CMake configuration to properly enable C++ exception handling on Android:

# Before: Exception handling disabled
add_link_options(-Wl,--no-eh-frame-hdr) # Disable the generation of .eh_frame_hdr section

# After: Exception handling enabled
add_compile_options(-fexceptions)  # Enable C++ exception handling
add_compile_options(-frtti)        # Enable runtime type information

Benefits

  • Architectural Fix: Addresses the root cause rather than working around it
  • Maintains Semantics: Invalid URLs continue to throw exceptions as expected
  • No API Changes: Existing C++ try-catch blocks now work correctly
  • Better Maintainability: Standard exception handling patterns work across platforms
  • Minimal Impact: Only CMake configuration changed, no code changes required

The fix ensures that when users enter invalid URLs, the existing error handling in content.cpp properly catches the Rust exception and logs an appropriate error message instead of crashing the application.

Fixes #155.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Copilot AI changed the title [WIP] When entering non-URL information, it is triggered by an android crash. Fix Android crash when parsing invalid URLs by handling errors gracefully Jul 29, 2025
Copilot AI requested a review from yorkie July 29, 2025 07:39
@EndlessJour9527 EndlessJour9527 marked this pull request as ready for review July 29, 2025 09:03
Copy link
Collaborator

@yorkie yorkie left a comment

Choose a reason for hiding this comment

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

On Android, cxx bridge exceptions aren't handled the same way as regular C++ exceptions

You should make sure the cmake configuration supports C++ exception instead of not throwing the exception.

…ead of Rust workaround

Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 29, 2025

On Android, cxx bridge exceptions aren't handled the same way as regular C++ exceptions

You should make sure the cmake configuration supports C++ exception instead of not throwing the exception.

You're absolutely right. I've fixed the CMake configuration to properly support C++ exceptions on Android instead of working around the issue in Rust code.

Changes made in commit 9f27870:

  1. Removed -Wl,--no-eh-frame-hdr - This flag was disabling exception frame headers on Android
  2. Added -fexceptions - Explicitly enables C++ exception handling
  3. Added -frtti - Enables runtime type information needed for proper exception handling
  4. Restored original Rust code - URL parsing now throws exceptions for invalid URLs as expected

This allows the existing try-catch block in content.cpp:382 to properly catch Rust exceptions, maintaining the correct architectural separation and error handling semantics.

Copilot AI changed the title Fix Android crash when parsing invalid URLs by handling errors gracefully Fix Android crash by enabling C++ exception handling in CMake configuration Jul 29, 2025
Copilot AI requested a review from yorkie July 29, 2025 10:08
@EndlessJour9527
Copy link
Collaborator

9f27870 Validate on the device

@yorkie yorkie force-pushed the copilot/fix-155 branch from 4c5b741 to fcd6575 Compare July 29, 2025 12:00
@yorkie yorkie merged commit f82ba0a into main Jul 29, 2025
1 of 2 checks passed
@yorkie yorkie deleted the copilot/fix-155 branch July 29, 2025 12:01
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.

When entering non-URL information, it is triggered by an android crash.

3 participants