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

[RN][Android] Fix <Image/> Logbox feedback loop #46280

Open
cipolleschi opened this issue Aug 30, 2024 · 8 comments
Open

[RN][Android] Fix <Image/> Logbox feedback loop #46280

cipolleschi opened this issue Aug 30, 2024 · 8 comments
Labels
Component: Image Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Platform: Android Android applications. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@cipolleschi
Copy link
Contributor

Description

When src is null, the <Image/> component displays a warning in LogBox.

The feedback loop:

  • Some component renders an <Image/>
  • Fabric preallocates the image, setting null src.
  • ReactImageView receives null src, emits warning.
  • Warning dispatches native -> js call, rendering LogBox, which uses <Image/>
  • Fabric preallocates the image, setting null src.
  • Goto 3

This feedback loop was originally deactivated in bridgeless.

Why: In step 4, this line would never execute: context.hasActiveReactInstance() would always return false. (ThemedReactContext was broken but we fixed it).

We should fix this feedback loop, and re-enable this warning in bridgeless.
Hint at a potential fix:

  • Prevent view preallocation from assigning a null src to preallocated views

Steps to reproduce

N/A

React Native Version

0.75.2

Affected Platforms

Runtime - Android

Areas

Fabric - The New Renderer

Output of npx react-native info

N/A

Stacktrace or Logs

N/A

Reproducer

https://github.com/facebook/react-native/packages/rn-tester

Screenshots and Videos

No response

@cipolleschi cipolleschi added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Aug 30, 2024
@react-native-bot react-native-bot added Component: Image Platform: Android Android applications. Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Aug 30, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@deepanshushuklad11
Copy link
Contributor

@cipolleschi can you please explain more about view preallocation ?

@cipolleschi
Copy link
Contributor Author

@deepanshushuklad11 Thanks for the interest in this issue! This is a task I created to mirror an internal task as we are collaborating with another company which is helping with some bugs. Let's leave this to them for the time being! ;)

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Aug 31, 2024
@coado
Copy link
Contributor

coado commented Sep 3, 2024

@cipolleschi I am not sure if I understand that correctly, but I think that warnImageSource is called only in the setSource function, which is called with uri props passed by the user, so the preallocation does not cause calling warnImageSource function or is it something that should also be added here?

For this code and with activating on bridgeless here, should it technically cause the feedback loop to happen in the current configuration?

import { Image, StyleSheet, SafeAreaView } from "react-native";

const IMAGE1 =
  'https://www.facebook.com/assets/fb_lite_messaging/[email protected]';


const App = () => {
  return (
    <SafeAreaView style={styles.container}>
      <Image style={styles.image} source={{ uri: IMAGE1 }} />
    </SafeAreaView>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  image: {
    width: 200,
    height: 200,
  },
})

export default App;

@cipolleschi
Copy link
Contributor Author

@coado As far as I understand, yes, it should happen. But I also think that the warning has been disabled in Bridgeless mode, so that's why you are not seeing it.
What happens if you assign {uri: null} to the image?

@coado
Copy link
Contributor

coado commented Sep 9, 2024

@coado As far as I understand, yes, it should happen. But I also think that the warning has been disabled in Bridgeless mode, so that's why you are not seeing it. What happens if you assign {uri: null} to the image?

When I remove !ReactFeatureFlags.enableBridgelessArchitecture from the if statement here (enabling on bridgeless) and set uri: IMAGE1 there is no warning. When I set uri: null there is a warning but no infinite loop.

@cipolleschi
Copy link
Contributor Author

cipolleschi commented Sep 10, 2024

ok, so perhaps this has been fixed somehow by some other fix and the responsible for the task internally forgot to close the task.
Potentially we could close this...

@RSNara could you help out and double check this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Image Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Platform: Android Android applications. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

4 participants