facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.21k stars 24.33k forks source link

[Android] FabricViewStateManager: setState called without a StateWrapper #32070

Closed KingAmo closed 8 months ago

KingAmo commented 3 years ago

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.

1. 2.

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 commented 3 years ago

image

efstathiosntonas commented 3 years ago

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

gigadeplex commented 3 years ago

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.

efstathiosntonas commented 3 years ago

@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

cloudychen commented 3 years ago

same here

Dsantacruz commented 3 years ago

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

aliraza-noon commented 3 years ago

facing the same issue can someone help please

Dsantacruz commented 3 years ago

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

Daha62 commented 3 years ago

same issue

kuenyu40 commented 3 years ago

same here

Levin-nik commented 3 years ago

same here

adhip94 commented 3 years ago

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.

Bayramito commented 3 years ago

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

aashu700 commented 3 years ago

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.

maaliHasan commented 3 years ago

same here!

mwegener-com commented 3 years ago

same problem

Bayramito commented 3 years ago

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

mwegener-com commented 3 years ago

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

Which hooks? All my used useState Hooks?

zrina1314 commented 2 years ago

same problem

tonyjaimep commented 2 years ago

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 πŸ€”

jqn commented 2 years ago

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 commented 2 years ago

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

feiyin0719 commented 2 years ago

it seem that it happened when ReactScrollView updateStateOnScroll

000xuandu commented 2 years ago

"react-native": "0.66.4"

The error message will show when scrolling Flatlist.

vr0707 commented 2 years ago

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

pritam-digichal commented 2 years ago

any progress in this issue?

andvalsol commented 2 years ago

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.

4) On ReactSrollView OnLayout() function calls reactScrollTo() 5) 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;
          }
        });

6) 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:

rateshb commented 2 years ago

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.

Kstar0722 commented 2 years ago

any updates on this issue?

abbasmashaddy72 commented 2 years ago

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

fogg4444 commented 2 years ago

This is happening for me, seeing the error unknown:FabricViewStateManager: setState called without a StateWrapper when clicking on a TextInput field on Android. Works just find on iOS. The keyboard closes immediately and that's the tell that there's something wrong.

garrettg123 commented 2 years ago

Happening for me on Android app launch "react-native-reanimated": "2.3.1", crashes app.

hamdidamar commented 2 years ago

same here, any update?

suwu150 commented 1 year ago

same here, any update?

techgerm commented 1 year ago

This is happening to us as well - we have the following dependencies that may be relevant:

"react-native": "0.66.4",
"react-native-reanimated": "2.13.0",
"@react-native-masked-view/masked-view": "^0.2.8",
"@react-navigation/bottom-tabs": "6.4.0",
"@react-navigation/drawer": "6.5.0",
"@react-navigation/native": "6.0.13",
"@react-navigation/native-stack": "6.9.1",
gaberogan commented 1 year ago

According to this, it looks like react-native-reanimated is not adding support for Fabric until v3.

Not sure if that's what is behind all this but it could be. I'm not sure why the error mentions Fabric when it should be disabled though πŸ€”

herujest commented 1 year ago

any update on this? it's happen in "react-native": "0.66.4". I also have this that might be relevant:

"react-native-reanimated": "^3.2.0",
"react-native-safe-area-context": "^4.3.1",
"@react-navigation/bottom-tabs": "^6.0.3",
"@react-navigation/native": "^6.0.2",
"@react-navigation/stack": "^6.0.4",
"react-native-screens": "^3.13.1",
vreoo commented 1 year ago

I ma facing the same issue. Any Update?

I am using:

"react-native": "0.66.5",
"react-native-gesture-handler": "2.9.0",
"react-native-reanimated": "^3.3.0",
"react-native-safe-area-context": "^4.5.3",
"@react-navigation/bottom-tabs": "^6.4.1",
"@react-navigation/compat": "^5.3.20",
"@react-navigation/drawer": "^6.4.4",
"@react-navigation/native": "^6.0.12",
"@react-navigation/stack": "^6.2.3",
ravindraguptacapgemini commented 1 year ago

@cortinico Are you guys looking into this issue, as this still happening on latest 0.72.1 with android.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 8 months ago

This issue was closed because it has been stalled for 7 days with no activity.

vreoo commented 7 months ago

@cortinico The issue is not yet resolved! It shouldn't be closed as it's still happening and we didn't get any explanation for the behaviour at all.

cortinico commented 7 months ago

@cortinico The issue is not yet resolved! It shouldn't be closed as it's still happening and we didn't get any explanation for the behaviour at all.

Please open a new issue and provide a valid reproducer, then we can look into it πŸ‘ We also need to make sure the issue still happens on 0.73.x or not

vreoo commented 7 months ago

@cortinico The issue is not yet resolved! It shouldn't be closed as it's still happening and we didn't get any explanation for the behaviour at all.

Please open a new issue and provide a valid reproducer, then we can look into it πŸ‘ We also need to make sure the issue still happens on 0.73.x or not

Fair enough, I totally agree with you. But It's very hard to reproduce this since it's only happening on production track + it happens with some users only (not all of them). We only get reports from the Google play console about the crashes with stack trace of the crash (along with device model and brand).

The only pattern I've noticed in my case, is that it happens only with the newest Android APIs (30 up to 34) not lower.

I was trying to reproduce this on my own many times, But I don't know where to start debugging for the issue or what to expect and what not or where to look and focus. In many cases the App is stuck on Splash screen after fresh install, or it opens then immediately crashes and never opens again. which doesn't happen to me at all when I try it myself (I tried many devices, but no luck).

AsteriskZuo commented 1 week ago

The above problem is related to ScrollView. fbd01f03f3fd1393701a5f824092aea9 e11211aac76ae0a4f9d7001f5fffb120