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 component reconstructed on split screen resize #25040

Closed
Jadeon-FPM opened this issue May 26, 2019 · 5 comments
Closed

(Android) App component reconstructed on split screen resize #25040

Jadeon-FPM opened this issue May 26, 2019 · 5 comments
Labels
Bug Platform: Android Android applications.

Comments

@Jadeon-FPM
Copy link

React Native version:

  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 405.22 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.14.1 - /usr/local/bin/node
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 26.0.2, 28.0.3, 29.0.0
        System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.5 => 0.59.5 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Steps To Reproduce

  1. Create a new project via react-native init AppName
  2. Add constructor with a console.log in the default app component (in App.js)
  3. Run the app

Expected behaviour

Switch to split-screen view or pop up view and resize the app window and continue to be able to use the app where it left off.

Actual behaviour

When switching to split screen or pop up view the app component is discarded and reconstructed, meaning the state of the app completely reset. The same thing happens when the app window is resized in this state.

I placed console.log at the top of both index.js and App.js (outside of any class or function) and inside the constructor the the default app class. The logs that were placed at the top of the two files were only called when the app was started while the one in the App constructor was called every time the app window was resized and the state was lost.

This tells me that the JS environment survives, but RN just reinitializes the app for whatever reason.

It seems to be the same as this issue that went stale and was never resolved.

@Jadeon-FPM Jadeon-FPM added the Bug label May 26, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label May 26, 2019
@alikazemkhanloo
Copy link

I tested with small changes to the size of the app. It doesn't rerender for small changes.

@Jadeon-FPM
Copy link
Author

It doesn't matter the size of the change, it always effectively restarts the app for me.

@artus9033
Copy link

+1 for that, happens on React Native 0.60 as well

@phunguyenmurcul
Copy link

This is a note from android developer:

To handle all Multi-Window related configuration changes use both "screenLayout" and "smallestScreenSize". Multi-Window is supported in Android 7.0 (API level 24) or higher.

You should add "screenLayout|smallestScreenSize" into "android:configChanges" to make it works

@Jadeon-FPM
Copy link
Author

This is a note from android developer:

To handle all Multi-Window related configuration changes use both "screenLayout" and "smallestScreenSize". Multi-Window is supported in Android 7.0 (API level 24) or higher.

You should add "screenLayout|smallestScreenSize" into "android:configChanges" to make it works

This worked for me actually! I'm surprised I couldn't find this listed anywhere. It should almost be included be default when the android project is generated.

facebook-github-bot pushed a commit that referenced this issue Nov 5, 2021
Summary:
When switching between split screen or resizing the screen window on Android causes a restart by reconstructing the app components as described on this issue #25040

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[Android] [Fixed] - Don't reconstruct app components #25040

Pull Request resolved: #32536

Test Plan:
### How to reproduce
- create a new project
-  build app and install on Android
- minimize app and start split screen
Expected:
- App enters split screen
Result:
- App restart

Same issue can be seen when resizing the split screen window

Reviewed By: cortinico

Differential Revision: D32175433

Pulled By: yungsters

fbshipit-source-id: 93dccaa134074eea260cca61eba2150444fa5688
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Platform: Android Android applications.
Projects
None yet
Development

No branches or pull requests

5 participants