Skip to content
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

android app link causes runApplication to be called again causing two instances of app running #16949

Closed
johnckendall opened this issue Nov 23, 2017 · 1 comment
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@johnckendall
Copy link

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

OS: macOS Sierra 10.12.6
Node: 8.3.0
Yarn: 1.3.2
npm: 5.5.1
Watchman: 4.3.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: ^0.50.2 => 0.50.3

Target Platform: iOS (8+)

Steps to Reproduce

  1. launch app
  2. touch home button
  3. click on an Android App Link configured to open app (i.e. https://www.myapp.com/go?i=cGnL3ls9duR2rwg)
  4. adb logcat will confirm the root element is never unmounted but gets mounted again

Expected Behavior

It should work identically to how it works in iOS. When the Android App Link is opened (either from a link on a web page or text message, etc) the app should come to the foreground and fire the AppState listener without re-mounting any components.

NOTE: If the app is opened by any other method this does not happen.

We have already added this to the manifest:
<!-- AndroidManifest.xml --> <activity ... android:launchMode="singleTop">

Actual Behavior

`[app launched from home screen]
11-23 10:11:28.471 21267 21267 D ReactNative: ReactInstanceManager.ctor()
11-23 10:11:28.478 21267 21267 D ReactNative: ReactInstanceManager.createReactContextInBackground()
11-23 10:11:28.478 21267 21267 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
11-23 10:11:28.478 21267 21267 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()
11-23 10:11:28.478 21267 21267 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
11-23 10:11:28.478 21267 21267 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
11-23 10:11:28.666 21267 21280 D ReactNative: ReactInstanceManager.createReactContext()
11-23 10:11:29.299 21267 21280 D ReactNative: Initializing React Xplat Bridge.
11-23 10:11:29.307 21267 21280 D ReactNative: Initializing React Xplat Bridge before initializeBridge
11-23 10:11:29.330 21267 21280 D ReactNative: Initializing React Xplat Bridge after initializeBridge
11-23 10:11:29.338 21267 21280 D ReactNative: CatalystInstanceImpl.runJSBundle()
11-23 10:11:29.353 21267 21287 D ReactNative: ReactInstanceManager.setupReactContext()
11-23 10:11:29.353 21267 21287 D ReactNative: CatalystInstanceImpl.initialize()
11-23 10:11:29.361 21267 21287 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
11-23 10:11:29.752 21267 21286 I ReactNativeJS: ******* CREATING NEW Utility **************
11-23 10:11:30.994 21267 21286 I ReactNativeJS: Running application "myapp" with appParams: {"rootTag":1}. DEV === false, development-level warning are OFF, performance optimizations are ON
11-23 10:11:31.025 21267 21286 I ReactNativeJS: App willMount (this is the root component in index.js)
11-23 10:11:31.025 21267 21286 I ReactNativeJS: App render
11-23 10:11:31.478 21267 21286 I ReactNativeJS: DeepLinker didMount
11-23 10:11:31.510 21267 21286 I ReactNativeJS: App didMount
11-23 10:11:31.518 21267 21286 I ReactNativeJS: 'DeepLinker APPSTATE:', 'active'
11-23 10:11:31.533 21267 21286 I ReactNativeJS: [ 'en-US' ]
11-23 10:11:31.580 21267 21286 I ReactNativeJS: TheList componentWillReceiveProps
11-23 10:11:31.674 21267 21286 I ReactNativeJS: TheList componentWillReceiveProps

[home button pressed]
11-23 10:11:45.674 21267 21286 I ReactNativeJS: 'DeepLinker APPSTATE:', 'background'

[Android App Link opened]
11-23 10:13:11.385 21267 21267 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
11-23 10:13:11.478 21267 21286 I ReactNativeJS: _Running application "myapp" with appParams: {"rootTag":11}. __DEV_ === false, development-level warning are OFF, performance optimizations are ON

[this is were root component (in index.js) is remounting]
11-23 10:13:11.494 21267 21286 I ReactNativeJS: App willMount
11-23 10:13:11.494 21267 21286 I ReactNativeJS: App render
11-23 10:13:11.564 21267 21286 I ReactNativeJS: myappList weillMount
11-23 10:13:11.705 21267 21286 I ReactNativeJS: DeepLinker didMount
11-23 10:13:11.705 21267 21286 I ReactNativeJS: App didMount

[now AppState is firing on both instances]
11-23 10:13:11.713 21267 21286 I ReactNativeJS: 'DeepLinker APPSTATE:', 'active'
11-23 10:13:11.713 21267 21286 I ReactNativeJS: 'DeepLinker APPSTATE:', 'active'
11-23 10:13:11.838 21267 21286 I ReactNativeJS: myappList componentWillReceiveProps
11-23 10:13:11.853 21267 21286 I ReactNativeJS: myappList componentWillReceiveProps

[pressing the hardware back button will "unload" the second instance but note that no unmounts are called]
11-23 10:13:11.971 21267 21286 I ReactNativeJS: 'nav reducer action', [ 'Navigation/BACK', undefined ]
11-23 10:13:11.971 21267 21286 I ReactNativeJS: 'nav reducer action', [ 'Navigation/NAVIGATE', 'myappView' ]
11-23 10:13:12.236 21267 21286 I ReactNativeJS: myappList componentWillReceiveProps
11-23 10:17:31.580 21267 21286 I ReactNativeJS: 'DeepLinker APPSTATE:', 'background'
11-23 10:17:31.588 21267 21286 I ReactNativeJS: 'DeepLinker APPSTATE:', 'background'
`

Reproducible Demo

This requires a web server configured to serve up the Android App Link as described here:
https://developer.android.com/training/app-links/index.html

Since we have not launched the app yet, we cannot provide a demo at this time. When we get closer to launch we may be able to provide this demo.

However, we would be willing to verify any solutions that are found. Again, this is working perfectly on iOS with Apple Deep Links.

Thanks!

@johnckendall johnckendall changed the title android app link causes re-mounting of the root component (but unmount never called) android app link causes runApplication to be called again causing two instances of app running Nov 23, 2017
@johnckendall
Copy link
Author

Changing launchMode to
<activity ... android:launchMode="singleInstance">

Seems to have fixed this issue for us so I'm closing this issue.

Hope this helps someone else out there ;-)

@facebook facebook locked as resolved and limited conversation to collaborators Nov 23, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Nov 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants