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

app is very slow in android Samsung 23 ultra #39183

Closed
rubbishCoder opened this issue Aug 28, 2023 · 48 comments
Closed

app is very slow in android Samsung 23 ultra #39183

rubbishCoder opened this issue Aug 28, 2023 · 48 comments
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@rubbishCoder
Copy link

rubbishCoder commented Aug 28, 2023

Description

App is very slow in Samsung devices especially in the android version 13 and also in the android logcat I get error

2023-08-28 17:37:37.826 1288-1288 LayerHistory | surfaceflinger | MainActivity$_27693#87452 Max (can't resolve refresh rate)

React Native Version

0.72.4

Output of npx react-native info

System:
OS: macOS 13.5.1
CPU: (10) arm64 Apple M1 Pro
Memory: 152.75 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.5.1
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 9.8.1
path: /opt/homebrew/bin/npm
Watchman:
version: 2023.08.14.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 22.4
- iOS 16.4
- macOS 13.3
- tvOS 16.4
- watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.10671973
Xcode:
version: 14.3.1/14E300c
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.20
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.4
wanted: 0.72.4
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false

Steps to reproduce

I just installed my app and run on the Samsung s23 ultra it was running fine but very slow and very bad response when I navigate. It takes around 10 seconds just to navigate, this issue occurs only in Samsung android devices. Is there any fix to it.

Snack, screenshot, or link to a repository

https://snack.expo.dev/qb7Cur_lU

@github-actions
Copy link

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.71.13. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@github-actions github-actions bot added the Platform: Android Android applications. label Aug 28, 2023
@AndreiCalazans
Copy link
Contributor

This seems unrelated to React Native core per say. What's likely impacting your navigation could be: the navigation library; a different JavaScript engine; animations; etc.,.

Can you add more information:

  1. What libraries are you using for navigation
  2. What JS engine are you using
  3. Is there any animations happening and if so how are they being executed
  4. Can you enable the performance monitor and see which thread is dropping frames when navigating (this can help indicate where to look)
  5. Does this also happen if you use a bare react native app with react-navigation on that phone?

And if this is a problem with core React Native a reproducible repo would help initialize an investigation. If this is core problem you should be able to create a reproduction with just a bare app and no external libraries.

@rubbishCoder
Copy link
Author

@AndreiCalazans animations or the navigation is not a problem, I thing the axis call is the one that cause the lag.

I tried to stop all the api calls and navigated between pages it was fine and rendering fast but when I do async or synchronous api calls the app is slow.

Using "axios": "1.5.0" and also I tried fetch which didn't have any impact, the app is still slow and navigations are very laggy if I make api calls, and this is occurring only in the android version 13 especially on the Samsung latest device like s22, s23.

Using below packages for navigation.

"@react-navigation/bottom-tabs": "^6.0.9", "@react-navigation/native": "^6.1.7", "@react-navigation/native-stack": "^6.2.5", "@react-navigation/stack": "^6.3.9",

Using Hermes js engine.

Lottie animation json is used to render animations "lottie-react-native": "^6.2.0".

Will create a repo with reproducible issue and update it.

@devoren
Copy link

devoren commented Aug 31, 2023

May be related to #36296

@AndreiCalazans
Copy link
Contributor

Possibly relate dto #36296, @rubbishCoder did you experience this slow down after upgrading? And yea, a reproduction sample can help us profile and see what's going on.

@rubbishCoder
Copy link
Author

@AndreiCalazans @devoren even after updating to latest version I'm facing this issue. And I'm not able to recreate this in a different project

@devoren
Copy link

devoren commented Sep 1, 2023

@rubbishCoder Can you downgrade to version 0.71.8 and see if there is a performance improvement?

@rubbishCoder
Copy link
Author

@rubbishCoder Can you downgrade to version 0.71.8 and see if there is a performance improvement?

@devoren okay I will downgrade and check it

@rubbishCoder
Copy link
Author

@devoren no effect after downgrading to 0.71.8

@devoren
Copy link

devoren commented Sep 1, 2023

@rubbishCoder oh, this is bad, then we just have to wait for a patch or release from the RN developers :(, in my case 0.71.8 is much better than 0.72

@rubbishCoder
Copy link
Author

@devoren does redux have anything to do with it?

@devoren
Copy link

devoren commented Sep 1, 2023

@rubbishCoder I think this is a problem on the engine side and RN Core. Redux is only on the js side so it doesn't affect that much, but if you have a large store and heavy functions then yes Redux can affect. You can debug components where used redux and see if it affects

@rubbishCoder
Copy link
Author

@devoren or @AndreiCalazans if I access redux state to set the stacks and also few data to be shown in bottom tab navigator, will it affect the navigation.

@AndreiCalazans
Copy link
Contributor

@rubbishCoder hard to say simply from your comment, your app is total black box to us, there could be many factors at play.

What's not clear to me in your issue is if this was a regression that occurred after you upgraded your React Native version or if this was something you just found out that is impacting users on Samsung 23 ultra devices?

I ask the above because there is an ongoing issue with people experience app wide performance degradation on versions 0.70.x + #36296

@rubbishCoder
Copy link
Author

@AndreiCalazans initially I found this issue on react-native 0.71.6. so later I upgraded it to 0.72.4 it was slightly better but still bad performance. It's not only occuring in s23 ultra, it's on Samsung devices with Android version 13.

@rubbishCoder
Copy link
Author

@AndreiCalazans @devoren when I do asynchronous api calls the response takes more time in android version 13. For example in IOS it took 1 second same call in android takes 15 secs. Any idea what will cause this.

@AndreiCalazans
Copy link
Contributor

@rubbishCoder can you try profiling it and comparing the iOS profilings with the Android? That's odd if the actual network request latency is the same. The difference could be the parsing of the request response so a profiling could help indicate where the time was spent. Save the CPU profilings and share it here for us to take a look.

See this for how to use chrome://inspect to profile performance.

@cortinico
Copy link
Contributor

Can we have a reproducer and a video to understand "how bad" is the regression?

@rubbishCoder
Copy link
Author

Can we have a reproducer and a video to understand "how bad" is the regression?

@cortinico
Like due to security reasons I can't share the video but for sure I see a delay in the API response that happens only in latest Samsung models. Like a API that takes 500ms in iOS and other android devices, but in Samsung s23 ultra it takes around 9 seconds. It's really weird.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Sep 13, 2023
@devoren
Copy link

devoren commented Sep 13, 2023

@rubbishCoder Have you debugged your API request? At what part does the query become slow?

@rubbishCoder
Copy link
Author

@rubbishCoder Have you debugged your API request? At what part does the query become slow?

@devoren

I make axios call and it take 10 seconds to return a response

@cortinico
Copy link
Contributor

Like due to security reasons I can't share the video

We can't provide any support without a reproducer (when I say reproducer I don't mean your project but another project that behaves similarly)

@devoren
Copy link

devoren commented Sep 13, 2023

I make axios call and it take 10 seconds to return a response

Did you check the time from the server when calling the request? Is the request on the server delayed by 10 seconds or does the response arrive with a delay of 10 seconds?

@cortinico cortinico removed the Needs: Attention Issues where the author has responded to feedback. label Oct 13, 2023
@rubbishCoder
Copy link
Author

@cortinico I tried removing persist and test in Samsung S23 its still the same behaviour no difference. Ram usage drastically got reduced but still the performance was bad in s23. So not sure which is causing the issue.

@cortinico
Copy link
Contributor

Again, without a reproducer we can't help in any form

@cortinico cortinico added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Oct 13, 2023
@github-actions
Copy link

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

@meetp-zluck
Copy link

We are having the same issue. Most of the samsung device are lagging with 2 of our react-native apps. I've sensed the lag in from a normal device to high end devices Samsung 22 ultra. Lag is there in tabs as well. But same things are working smooth in other Brands devices from 4 years ago.

If anyone knows any workarounds or patches, I'd really appreciate. Thanks!

@PradeepKK13
Copy link

@rubbishCoder can you try profiling it and comparing the iOS profilings with the Android? That's odd if the actual network request latency is the same. The difference could be the parsing of the request response so a profiling could help indicate where the time was spent. Save the CPU profilings and share it here for us to take a look.

See this for how to use chrome://inspect to profile performance.

@cortinico @AndreiCalazans We had done the profiling and captured the trace from Samsung S23 Ultra and Oneplus 9pro. Sharing the trace for reference. Oneplus is working fine without any lag in network or in rendering but Samsung there is lag in both network and rendering.

Trace: https://drive.google.com/drive/folders/1f441btiLRdcpAwtktWhBrd8QHQN2yvL9?usp=sharing

@AndreiCalazans
Copy link
Contributor

AndreiCalazans commented Nov 22, 2023

@PradeepKK13 this is helpful.

One thing that stood out while comparing those two traces is native module traces of callJavaModuleMethod are much slower on the Samsung S23 Ultra which is odd given that the S23 Ultra is a higher end phone.

This seems to be due to binder transactions taking much longer.

Evidence:

Traces to callJavaModuleMethod are faster on Oneplus

Screenshot 2023-11-22 at 10 43 37

Note calls are at 36ms

Querying for max and averages

Screenshot 2023-11-22 at 10 43 04

Max at 113ms while average is 0.8ms

On S23 Ultra

Screenshot 2023-11-22 at 10 44 00

We see multiple callJavaModuleMethod calls taking 200ms and more

Screenshot 2023-11-22 at 10 42 49

Max at 300ms while average is 2.91ms

Looking at the binder transactions we confirm slower binder transactions:

Screenshot 2023-11-22 at 10 48 10

Summary:

callJavaModuleMethod OnePlus S23 Ultra
Average 0.8ms 2.9ms
Max 113ms 300ms
Observed 36ms 223ms

@PradeepKK13 it's not obvious if this is the reason for a slower rendering and networking but it could be. Can you do the same trace on this same Samsung S23 Ultra device using the previous React Native version that had no lag? This could help us compare the two traces and validate if the binder transactions got slower or were the same.

@PradeepKK13
Copy link

@PradeepKK13 this is helpful.

One thing that stood out while comparing those two traces is native module traces of callJavaModuleMethod are much slower on the Samsung S23 Ultra which is odd given that the S23 Ultra is a higher end phone.

This seems to be due to binder transactions taking much longer.

Evidence:

Traces to callJavaModuleMethod are faster on Oneplus

Screenshot 2023-11-22 at 10 43 37 _Note calls are at 36ms_

Querying for max and averages

Screenshot 2023-11-22 at 10 43 04 _Max at 113ms while average is 0.8ms_

On S23 Ultra

Screenshot 2023-11-22 at 10 44 00 _We see multiple `callJavaModuleMethod` calls taking 200ms and more_ Screenshot 2023-11-22 at 10 42 49 _Max at 300ms while average is 2.91ms_

Looking at the binder transactions we confirm slower binder transactions:

Screenshot 2023-11-22 at 10 48 10 Summary:

callJavaModuleMethod OnePlus S23 Ultra
Average 0.8ms 2.9ms
Max 113ms 300ms
Observed 36ms 223ms
@PradeepKK13 it's not obvious if this is the reason for a slower rendering and networking but it could be. Can you do the same trace on this same Samsung S23 Ultra device using the previous React Native version that had no lag? This could help us compare the two traces and validate if the binder transactions got slower or were the same.

@AndreiCalazans Thanks for your insights. Unfortunately we don't have a React Native version in which there was no lag. Initial project was in 0.71.6 version which had the same lag and then we upgraded to 0.72.4 version which made no difference.

@diegolmello
Copy link

@PradeepKK13 can you try downgrading to 0.68?
It might help proving my point on #36296 (comment) and help getting visibility to this issue.
Thanks!

@chramos
Copy link

chramos commented Nov 28, 2023

We are using 0.64.4 and we are also experiencing a really slow performance on Samsung s23.
Hermes is turned on for a long time (2 years approx.)
honestly, I never felt any improvement on turning on/off Hermes.
I'm going to turn it off and test
I come back to let you know

@nilsrk
Copy link

nilsrk commented Dec 14, 2023

Also having issues running my React Native app on a OnePlus with OxygenOS (based on Android 13.x), very laggy

@aymericBerettoni
Copy link

hello, same issue for me, on an application that has been running without problem for 2 years, Issues on galaxy s23, has anyone been able to solve it?

Copy link

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 12, 2024
@hthieu1110
Copy link

I'm facing the same issue on Android using Exynos CPU. It's working very well on an Snapdragon one.
The network call is very slow : 5s vs 100ms on iPhone but I think the source of problem is the rendering which blocks the JS thread. Do we have any news on this thread ?

@github-actions github-actions bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 18, 2024
Copy link

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 11, 2024
@GuillaumeHemmen
Copy link

Can the stalebot be disabled on this one? This seems related to #36296 so i believe that is pertinent to keep it open.

@github-actions github-actions bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 12, 2024
Copy link

github-actions bot commented Mar 7, 2024

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 7, 2024
Copy link

This issue was closed because the author hasn't provided the requested feedback after 7 days.

1 similar comment
Copy link

This issue was closed because the author hasn't provided the requested feedback after 7 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2024
@dorshay6
Copy link

We are also facing that issue, any idea on whats next?

@pavelustenko
Copy link

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests