react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android] FabricViewStateManager: setState called without a StateWrapper

Open KingAmo opened this issue 2 years ago • 31 comments

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

i have no idea what is wrong , but i app get stuck and logcat print FabricViewStateManager: setState called without a StateWrapper repeatedly

React Native version:

Run react-native info in your terminal and copy the results here.

System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 2.38 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.19.0 - /usr/local/bin/node
    Yarn: 1.22.5 - ~/.yarn/bin/yarn
    npm: 7.19.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 21, 23, 25, 26, 27, 28, 29, 30
      Build Tools: 23.0.1, 26.0.1, 26.0.2, 27.0.3, 28.0.3, 29.0.2
      System Images: android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7621141
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_212 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.2 => 17.0.2
    react-native: ^0.64.1 => 0.64.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

Expected Results

Describe what you expected to happen.

Snack, code example, screenshot, or link to a repository:

Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

KingAmo avatar Aug 23 '21 11:08 KingAmo

image

KingAmo avatar Aug 23 '21 11:08 KingAmo

same here on 0.65, error is incredibly crypted, google returns really few results.

efstathiosntonas avatar Aug 24 '21 10:08 efstathiosntonas

Yeah, I had this problem too. I downgraded to 0.64.2 and it stopped crashing. :) Don't know what's wrong with the 65 though, I liked it a lot until it started crashing.

gigadeplex avatar Aug 24 '21 15:08 gigadeplex

@gigadeplex it's not only on 0.65.x, it happened to me on 0.64.x too, it would be great if someone from facebook team explain why this is throwing. In my case it won't crash the app

efstathiosntonas avatar Aug 25 '21 07:08 efstathiosntonas

same here

cloudychen avatar Sep 09 '21 10:09 cloudychen

The same thing just happened to me, after installing react navigation drawer and reanimated 2, now the app crashes and the screen goes blank, help me

Dsantacruz avatar Sep 10 '21 09:09 Dsantacruz

facing the same issue can someone help please

aliraza-noon avatar Sep 20 '21 10:09 aliraza-noon

I solved it by migrating my logic to a new project of react native 0.65.1 with the latest versions of react navigation

Dsantacruz avatar Sep 21 '21 22:09 Dsantacruz

same issue

Daha62 avatar Sep 22 '21 10:09 Daha62

same here

kuenyu40 avatar Sep 23 '21 09:09 kuenyu40

same here

Levin-nik avatar Sep 24 '21 06:09 Levin-nik

My app uses RN 0.65.1 with react-native-reanimated v2.2.2 and it was facing this issue on android. I updated react-native-reanimated to v2.3.0-beta.2 and in my initial testing I cannot replicate this issue now.

adhip94 avatar Oct 11 '21 17:10 adhip94

+1 same issue, any solutions except upgrading to 2.3.x ?

Bayramito avatar Oct 15 '21 10:10 Bayramito

I was also facing this issue, I was using @react-navigation/stack. I simply moved to @react-navigation/native-stack and the issue is resolved for me. may help.

"@react-navigation/drawer": "^6.1.8", "@react-navigation/native": "^6.0.6", "@react-navigation/native-stack": "^6.2.5", "react-native-reanimated": "^2.2.0", "react": "17.0.1", "react-native": "0.64.2",

happy coding. all the best.

aashu700 avatar Oct 28 '21 05:10 aashu700

same here!

maaliHasan avatar Oct 31 '21 11:10 maaliHasan

same problem

mwegener-com avatar Nov 02 '21 19:11 mwegener-com

Just import the hooks from the navigation/native not from the core. Like useRoute, useNavigation, usScrollToTop

Bayramito avatar Nov 02 '21 19:11 Bayramito

Just import the hooks from the navigation/native not from the core. Like useRoute, useNavigation, usScrollToTop

Which hooks? All my used useState Hooks?

mwegener-com avatar Nov 03 '21 12:11 mwegener-com

same problem

zrina1314 avatar Nov 17 '21 13:11 zrina1314

I got the same both on Android and iOS, the "solution" I had was to call console.log close to where the error was raised, somehow that works 🤔

tonyjaimep avatar Nov 25 '21 01:11 tonyjaimep

For me this error shows up when I import a TextInput component. I'm on RN version 0.67.0 and it maches the screen shot in this issue https://github.com/facebook/react-native/issues/32114

jqn avatar Jan 28 '22 12:01 jqn

Ok, my issue wasn't the same as this one please view https://github.com/facebook/react-native/issues/31572 for a workaround

jqn avatar Jan 28 '22 12:01 jqn

it seem that it happened when ReactScrollView updateStateOnScroll

feiyin0719 avatar Feb 10 '22 06:02 feiyin0719

"react-native": "0.66.4"

The error message will show when scrolling Flatlist.

000xuandu avatar Feb 21 '22 15:02 000xuandu

This same error to showed my logcat. But I worked on Curved navigation bar, after routing not worked and crashed and showed this error..

vr0707 avatar Mar 29 '22 04:03 vr0707

any progress in this issue?

pritam-digichal avatar May 03 '22 06:05 pritam-digichal

I'm also experiencing the same issue, after debugging, here's the flow that originates the issue:

  1. NativeViewHierarchyManager gets called on the method createView() which passes the stateWrapper as null
  2. The call from 1) calls createView() from ViewManager (with a null stateWrapper).
  3. The call from 2) calls onCreateViewInstance which has the following logic:
if (stateWrapper != null) {
      Object extraData = updateState(view, initialProps, stateWrapper);
      if (extraData != null) {
        updateExtraData(view, extraData);
      }
    }

Because the stateWrapper is null, the ViewManager 's updateState() won't be called.

  1. On ReactSrollView OnLayout() function calls reactScrollTo()
  2. reactScrollTo() function calls updateStateOnScroll() which has the following logic:

mFabricViewStateManager.setState(
        new FabricViewStateManager.StateUpdateCallback() {
          @Override
          public WritableMap getStateUpdate() {

            WritableMap map = new WritableNativeMap();
            map.putDouble(CONTENT_OFFSET_LEFT, PixelUtil.toDIPFromPixel(scrollX));
            map.putDouble(CONTENT_OFFSET_TOP, PixelUtil.toDIPFromPixel(scrollY));
            return map;
          }
        });
  1. The setState()function has the following logic:
if (stateWrapper == null) {
      FLog.e(TAG, "setState called without a StateWrapper");
      return;
    }

This is the flow that I've seen in a project I'm working on. I have the following questions:

  • Should the initial createView() must set stateWrapper to null at first?
  • If the answer to the first question is yes, at what stage does the stateWrapper gets updated?

andvalsol avatar May 04 '22 22:05 andvalsol

Any update on this issue? I can run my app of the Expo platform without any issues, however when I am running it on the emulator it starts throwing this error and app stops working properly. Stuck for a few days, please help.

rateshb avatar Jul 14 '22 17:07 rateshb

any updates on this issue?

Kstar0722 avatar Aug 31 '22 05:08 Kstar0722

Any Update on This Issue, It Still Occurs from Me Also

abbasmashaddy72 avatar Oct 02 '22 20:10 abbasmashaddy72