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

Multiline controlled input enters an infinite loop on iOS #46850

Open
gaearon opened this issue Oct 5, 2024 · 4 comments
Open

Multiline controlled input enters an infinite loop on iOS #46850

gaearon opened this issue Oct 5, 2024 · 4 comments
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Platform: iOS iOS applications.

Comments

@gaearon
Copy link
Collaborator

gaearon commented Oct 5, 2024

Description

This code enters an infinite loop on iOS.

import React, {useState, memo} from 'react'
import {TextInput} from 'react-native'

let App = () => {
  console.log('render App')
  const [outlet, setOutlet] = useState(null)
  return (
    <>
      <Outlet outlet={outlet} />
      <Child setOutlet={setOutlet} />
    </>
  )
}
export default App

let Child = memo(({setOutlet}) => {
  console.log('render Child')
  const [value, setValue] = useState('')
  return (
    <Portal setOutlet={setOutlet}>
      <TextInput
        onChangeText={text => setValue(text)}
        value={value}
        multiline
        style={{
          backgroundColor: 'red',
          marginTop: 200,
        }}
      />
    </Portal>
  )
})

let Outlet = memo(({outlet}) => {
  console.log('render Outlet')
  return outlet
})

let Portal = memo(({children, setOutlet}) => {
  console.log('render Portal')
  React.useLayoutEffect(() => {
    setOutlet(children)
  }, [children])
  return null
})

Removing multiline prop fixes the issue.

I suspect this may be related to #36494 but who knows.

Steps to reproduce

See above

React Native Version

0.75.4

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.6.1
  CPU: (16) arm64 Apple M3 Max
  Memory: 53.04 GB / 128.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.8.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.09.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

n/a

Reproducer

https://github.com/gaearon/rn-bug-loop

Screenshots and Videos

loop.mov
@gaearon
Copy link
Collaborator Author

gaearon commented Oct 5, 2024

Btw I think this may be fixed in Fabric but not 100% sure. I'll try to check

@cortinico cortinico added Never gets stale Prevent those issues and PRs from getting stale Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Triage 🔍 Never gets stale Prevent those issues and PRs from getting stale labels Oct 7, 2024
@Darhagonable
Copy link

@cortinico What priority does this issue have? Controlled inputs working should be considered fundamental and high priority.

@cortinico
Copy link
Contributor

@cortinico What priority does this issue have? Controlled inputs working should be considered fundamental and high priority.

Just following up here. This is definitely a problem we want to look into.
@NickGerleman is the best person to look into this, but he's currently off so we won't be able to provide any updates on this issue for a couple of weeks at the moment

@NickGerleman
Copy link
Contributor

I'm back from PTO today, and going through things, but wanted to check if this still repros on new arch, given the above comment.

In general, we've been wanting to treat old arch specific code as somewhat frozen, since none of our production apps are using it anymore, meaning we won't get much signal if we introduce new bugs or crashes (e.g. some of my new-arch specific iOS text fixes just generated a low-hitting crash that came to me last week).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Platform: iOS iOS applications.
Projects
None yet
Development

No branches or pull requests

6 participants
@gaearon @NickGerleman @cortinico @Darhagonable @react-native-bot and others