react-native: React Native freezes UI when fetching response from API

Description

I’m facing a weird problem on old devices with react native apps. I realized that it happens with all the apps that I had developed with RN. Every time that I do a request to API the UI freezes until the request is responded. I have published 5 apps on Google Play store when the problem is the same. I don’t know what to do. I need some help to solve it. Even the most recent version of RN (0.70.3) I’m getting this problem. Just to let you know I’m using axios with redux saga and I tried to use just fetch API but the problem still the same.

Version

0.70.3

Output of npx react-native info

System: OS: Windows 10 10.0.22000 CPU: (8) x64 11th Gen Intel® Core™ i7-11390H @ 3.40GHz Memory: 6.72 GB / 15.74 GB Binaries: Node: 16.17.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 23, 28, 29, 30, 31, 32 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0 System Images: android-26 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: AI-213.7172.25.2113.9014738 Visual Studio: 17.3.32819.101 (Visual Studio Enterprise 2022) Languages: Java: 18.0.1.1 - C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.3 => 0.70.3 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Nothing

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

Nothing

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 14
  • Comments: 18 (1 by maintainers)

Most upvoted comments

We are no longer having this issue in 0.71+

Can anyone from the Meta team help here?

We are facing the same issue with Hermes enabled

cc @cortinico @fortmarek @kelset

Facing same issue

What I realized is that it is not the request that freezes the UI, it is the promise of parsing of the response that needs to resolve before the main thread is unblocked. If you’re using Apollo, this happens by default, if you’re using fetch then it is either .text() or .json().

My solution was to use rn-fetch-blob and save the response as a file and parse from there.

Can anyone from the Meta team help here?

Can we get a reproducer of some sort?