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

Bug: render time differ depending on load #28886

Open
freeboub opened this issue Apr 21, 2024 · 0 comments
Open

Bug: render time differ depending on load #28886

freeboub opened this issue Apr 21, 2024 · 0 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@freeboub
Copy link

freeboub commented Apr 21, 2024

React version: 18.2.0

Steps To Reproduce

1/ Create a heavy component to display

can be simulated with something like:

const HeavyComponent = () => {
const start = performance.now()
let i = 0;
while (i < 9000000) {
i = i + 1;
}
console.log('render time', performance.now() - start)
return null;
};
`
2/ force refreshing this component periodically with a setInterval.

const App = () => {
// eslint-disable-next-line no-unused-vars
const [_time, setTime] = useState(0);
// setState in an interval to for refresh periodically
useEffect(() => {
const interval = setInterval(() => {
setTime(_time => _time + 1);
}, timeout);
return () => clearInterval(interval)
}, []);
return <HeavyComponent />;
};

BUG
Depending on the timeout configured (ie refresh frequency) the execution time of HeavyComponent differs (one to the double).

Output in console:
When putting a low timeout (10ms), the average render time is around 2.7 ms
When putting a high timeout (100ms), the average render time is around 6 ms

A very basic sample sample is available here (with the code I put on the ticket):
Link to code example: https://github.com/freeboub/ReactSampleForDevTool

The current behavior

The execution time is not consistent depending on app load

The expected behavior

The execution time should be consistent depending on app load

additional informations

  • I was investigating this issue in a react native project. -> issue highlighted with react dev tool.
  • The result are consistent with profiler output (I can share screenshots if needed).
  • Changing the HeavyComponent render time also gives consistent one to double refresh time.
  • I was investigating this issue with profiler, but as console.log also highlight the issue, I kept it.
  • There is maybe an explanation for this behavior, but was not able to find it in bugtracker nor on any other internet link.
  • Same behavior observed with
    "react": "^19.0.0-canary-33a32441e9-20240418",
    "react-dom": "^19.0.0-canary-33a32441e9-20240418",

Thank you !

@freeboub freeboub added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

1 participant