App restarts after being opened with deep link from Chrome Custom Tab on Android

Please provide the following:

  1. SDK Version:
    Expo CLI 3.8.0 environment info:
    System:
    OS: macOS 10.14.6
    Shell: 3.2.57 - /bin/bash
    Binaries:
    Node: 10.15.3 - /usr/local/bin/node
    npm: 6.4.1 - /usr/local/bin/npm
    IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 11.2/11B52 - /usr/bin/xcodebuild
    npmPackages:
    expo: ^35.0.0 => 35.0.0
    react: 16.8.3 => 16.8.3
    react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8
    react-navigation: ^4.0.9 => 4.0.9
    npmGlobalPackages:
    expo-cli: 3.8.0
  2. Platforms(Android/iOS/web/all):
    Android (can reproduce most of the time in both Android standalone and Android in the Expo client, but only if I build with expo start --no-dev --minify

I am using Expo along with the AWS Amplify Auth library. I have no issues on iOS. On Android, when running in minified production mode (see platforms above), most of the time my app restarts without any error (kicks me back to the splash screen) not long after sign in.

This means that my app is unusable on Android.

The issue occurs right after the Chrome Custom Tab call the app deep link URL that was generated by Expo’s Linking.makeUrl().

I am running out of ideas for how to troubleshoot this issue, so I thought I’d turn here for help. If I hook up the debugger with logcat, I don’t see anything other than my normal console.log statements. When I compare the console.log statements from the rare occurrence when the app does work to when it, most of the time, restarts, I see no difference.

I have had to patch the AWS Amplify Auth’s urlListener in order to get around a reported Expo issue where deep links fire a bunch of times over and over again, so it could be that that is still related, but if so I can’t tell. This is similar to my workaround:

From what I can see, the issue has something to do with Linking, and being directed back to the app via the deep link to it. When debugging, I can see that, even while the app is continuing to do other things (it doesn’t appear to be crashing), it looks like a new instance is starting up:

[a bunch of my app's console.log statement's...]
11-19 16:57:04.152 30736 30736 D ReactNative: ReactInstanceManager.ctor()
11-19 16:57:04.187 30736 30736 D ReactNative: ReactInstanceManager.createReactContextInBackground()
11-19 16:57:04.187 30736 30736 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
11-19 16:57:04.187 30736 30736 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()
11-19 16:57:04.187 30736 30736 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
11-19 16:57:04.187 30736 30736 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
11-19 16:57:04.191 30736 31765 D ReactNative: ReactInstanceManager.createReactContext()
11-19 16:57:04.292 30736 31765 D ReactNative: Initializing React Xplat Bridge.
11-19 16:57:04.325 30736 31765 D ReactNative: Initializing React Xplat Bridge before initializeBridge
11-19 16:57:04.348 30736 31765 D ReactNative: Initializing React Xplat Bridge after initializeBridge
11-19 16:57:04.348 30736 31765 D ReactNative: CatalystInstanceImpl.runJSBundle()
11-19 16:57:04.350 30736 31767 D ReactNative: ReactInstanceManager.setupReactContext()
11-19 16:57:04.351 30736 31767 D ReactNative: CatalystInstanceImpl.initialize()
11-19 16:57:04.360 30736 31767 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
11-19 16:57:04.700 30736 30736 D ReactNative: CatalystInstanceImpl.destroy() start
11-19 16:57:05.020 30736 30764 D ReactNative: CatalystInstanceImpl.destroy() end
11-19 16:57:07.982 30736 31766 I ReactNativeJS: Running application "main" with appParams:

This issue persists. As far as I can see, it is a timing issue, as 9 out of 10 times the issue occurs. 1 out of 10 times it does not. This is true on the same device, same app version, just executing the same scenario/steps over and over again.

Still looking for any suggestions.

Suddenly it sounds like there is hope, as this issue appears to describe exactly what I have been experiencing: AuthSession returns dismiss result even before the browser is opened · Issue #6679 · expo/expo · GitHub

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.