Skip to content

The app crashes if iosCustomBrowser is not provided, react-native 0.77.1 #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mluksha opened this issue Feb 19, 2025 · 11 comments
Open

Comments

@mluksha
Copy link

mluksha commented Feb 19, 2025

Issue

The release configuration of the app crashes on iOS if authorize method is called without iosCustomBrowser option. It reproduces only with react-native v0.77.1.

- (id<OIDExternalUserAgent>)getCustomBrowser: (NSString *) browserType {
    typedef id<OIDExternalUserAgent> (^BrowserBlock)(void);
    
    NSDictionary *browsers = @{
        @"safari":
            ^{
                return [OIDExternalUserAgentIOSCustomBrowser CustomBrowserSafari];
            },
        @"chrome":
            ^{
                return [OIDExternalUserAgentIOSCustomBrowser CustomBrowserChrome];
            },
        @"opera":
            ^{
                return [OIDExternalUserAgentIOSCustomBrowser CustomBrowserOpera];
            },
        @"firefox":
            ^{
                return [OIDExternalUserAgentIOSCustomBrowser CustomBrowserFirefox];
            }
    };
    BrowserBlock browser = browsers[browserType];
    return browser();  <-- Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)
}

Environment

  • Your Identity Provider: IdentityServer 4
  • Platform that you're experiencing the issue on: iOS (only release configuration)
  • Your react-native Version: 0.77.1
  • Your react-native-app-auth Version: 8.0.0
  • Are you using Expo?: 52.0.35
@tuladharjaa
Copy link

I also am facing this issue. It works fine on iOS simulator

@SunlightKnight
Copy link

I'm facing the same issue:

  • react-native: 0.77.1
  • react-native-app-auth: 8.0.1

Seems to be working fine while debugging (either on the simulator or on the device), but the release build crashes at the return browser() line.

@ksm
Copy link

ksm commented Feb 26, 2025

Hello folks. The app I work on also just hit this issue.

The snippet where the problem happens is here. Specifically:

id<OIDExternalUserAgent> externalUserAgent = iosCustomBrowser != nil ? [self getCustomBrowser: iosCustomBrowser] : nil;

iosCustomBrowser != nil evaluates to true even though iosCustomBrowser is not passed in to the JavaScript API (it is undefined). Not sure why this is happening, but it looks like it started happening with RN 0.77.1.

The workaround I found is heavy handed but effective. I used patch-package to set this line of code to id<OIDExternalUserAgent> externalUserAgent = nil, which effectively disables the iosCustomBrowser API, but also solves the crash.

Lastly this issue is only reproducible in release builds. So in order to see it happen in the iOS simulator you must build a release build (not a debug build).

@ksm
Copy link

ksm commented Feb 26, 2025

Here is the cause. See official changelog for react-native 0.77.1:

Interop Layer: Properly handle null values coming from NativeModules. (475f797a51 by sammy-SC)

@SunlightKnight
Copy link

SunlightKnight commented Feb 26, 2025

Hi @ksm and thanks a lot for finding the cause of the problem. I'll be using the patch you provided for now, since I need the app I'm working on to be usable. Hope they will update this package soon.

@valentinrey
Copy link
Contributor

valentinrey commented Mar 5, 2025

Is there any planned work on this issue? I'm asking because I cannot use the patch, since that open a regular browser session and I need to open an ephemeral browser in private modus for authentication

@valentinrey
Copy link
Contributor

It happens with react-native Version: 0.78.0 as well

@dmohler20
Copy link

I am also having the same issue. Hopefully there will be a fix soon.

@valentinrey
Copy link
Contributor

I made a PR for the other issue I opened that truly may fix this issue as well (I think is the same issue)

#1064

@SunlightKnight
Copy link

I made a PR for the other issue I opened that truly may fix this issue as well (I think is the same issue)

#1064

It's the same issue, actually, but your PR has solved the problem. Thanks a lot!

@valentinrey
Copy link
Contributor

I made a PR for the other issue I opened that truly may fix this issue as well (I think is the same issue)
#1064

It's the same issue, actually, but your PR has solved the problem. Thanks a lot!

You're welcome! My app is made in bare RN and I'm planning to move it to Expo, but I need some time to do it :)

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

No branches or pull requests

6 participants