facebook / react-native

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

Secure text entry flickers on iOS #45347

Open atlj opened 1 month ago

atlj commented 1 month ago

Description

On iOS (With a Simulator or a real device), if you have a TextInput component with secureTextEntry={true} and a custom font, the text flickers when you enter a character and remove it.

Note: this also happens with the old renderer.

Steps to reproduce

  1. Install the application with yarn ios
  2. Focus on the text input
  3. Enter a character and then remove it

React Native Version

0.74.3

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

System:
  OS: macOS 14.3
  CPU: (10) arm64 Apple M1 Pro
  Memory: 98.19 MB / 16.00 GB
  Shell:
    version: 0.91.0
    path: /Users/burakguner/.cargo/bin/nu
Binaries:
  Node:
    version: 21.7.1
    path: ~/.nix-profile/bin/node
  Yarn:
    version: 4.3.1
    path: ~/.nix-profile/bin/yarn
  npm:
    version: 10.5.0
    path: ~/.nix-profile/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /Users/burakguner/.nix-profile/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/burakguner/.local/share/gem/ruby/3.1.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: Hedgehog 2023.1.1 Patch 2 Hedgehog 2023.1.1 Patch 2
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.8
    path: /usr/bin/javac
  Ruby:
    version: 3.1.4
    path: /Users/burakguner/.nix-profile/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: true

### Stacktrace or Logs

```text
There is no stack trace.

Reproducer

https://github.com/atlj/secure-text-entry-flicker

Screenshots and Videos

https://github.com/facebook/react-native/assets/23079646/7a260380-eb2c-434c-97f3-af14dd51a5af

shubhamguptadream11 commented 1 month ago

It's not reproducible at my end. React-native: 0.74.3 iOS: iPhone 15 Pro 17.0 New Architecture enabled @atlj Attached a reference. Is this device specific? https://github.com/facebook/react-native/assets/85783070/cc2028ff-d754-4332-9f6a-310b67367b13

atlj commented 1 month ago

Hey @shubhamguptadream11 I was able to see the issue on:

Are you using an external keyboard? You have to use the screen keyboard, otherwise the characters you just entered aren't visible

cortinico commented 1 month ago

With flickers do you mean the dots moving slightly up and down?

atlj commented 1 month ago

With flickers do you mean the dots moving slightly up and down?

Yes exactly and it gets more noticable when the fontSize is larger

shubhamguptadream11 commented 1 month ago

Hey @atlj, I tried this again with simulator keyboard. Not reproducible at my end.

Device info are same as shared above.

https://github.com/facebook/react-native/assets/85783070/32f43f7c-22b4-4da9-98e5-2da3f2511144

atlj commented 1 month ago

Hey @shubhamguptadream11 I'm not entirely sure why but it looks like your app still uses the default font since it's not bold. The letters you typed seem a bit light to me and I can verify there is no issue with the default font.

DimitarNestorov commented 1 month ago

I cloned @atlj's reproducer, ran it in Simulator, enabled software keyboard, entered some letters, and could observe the same issue. Then I ran it on iPhone 12 and got the same result.

https://github.com/facebook/react-native/assets/8790386/fe5a93a8-2e9d-4a55-bc35-8bf47d1186a5

cc @shubhamguptadream11

Hammad089 commented 1 month ago

use secureTextEntry={true} to fix that