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

Fix FpsDebugFrameCallback so that we properly cancel frame loop to avoid race #38671

Closed
wants to merge 1 commit into from

Conversation

ryancat
Copy link
Contributor

@ryancat ryancat commented Jul 28, 2023

Summary:
Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the mShouldStop flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees stop would queue logic that removes the frame loop callback, and a later start would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Differential Revision: D47849848

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Jul 28, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

ryancat pushed a commit to ryancat/react-native that referenced this pull request Jul 28, 2023
…oid race (facebook#38671)

Summary:
Pull Request resolved: facebook#38671

Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the  `mShouldStop` flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees `stop` would queue logic that removes the frame loop callback, and a later `start` would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Differential Revision: D47849848

fbshipit-source-id: cd87d418ad4115aac7d7905e6cb8dda39939bcc0
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

@analysis-bot
Copy link

analysis-bot commented Jul 28, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,965,153 +534
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 9,556,333 -85
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: eb5e7b2
Branch: main

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

ryancat pushed a commit to ryancat/react-native that referenced this pull request Aug 3, 2023
…oid race (facebook#38671)

Summary:
Pull Request resolved: facebook#38671

Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the  `mShouldStop` flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees `stop` would queue logic that removes the frame loop callback, and a later `start` would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Reviewed By: hoxyq

Differential Revision: D47849848

fbshipit-source-id: 0509ffef38a21000994fbdf6325acc72bddb592f
ryancat pushed a commit to ryancat/react-native that referenced this pull request Aug 3, 2023
…oid race (facebook#38671)

Summary:
Pull Request resolved: facebook#38671

Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the  `mShouldStop` flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees `stop` would queue logic that removes the frame loop callback, and a later `start` would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Reviewed By: hoxyq

Differential Revision: D47849848

fbshipit-source-id: 6dfa403e493df6a50bfb07dbb1469843aaf05f6e
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

ryancat pushed a commit to ryancat/react-native that referenced this pull request Aug 31, 2023
…oid race (facebook#38671)

Summary:
Pull Request resolved: facebook#38671

Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the  `mShouldStop` flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees `stop` would queue logic that removes the frame loop callback, and a later `start` would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Reviewed By: hoxyq

Differential Revision: D47849848

fbshipit-source-id: 2ce2e87470f690f51e852493c27cd6fe1d6bf874
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

ryancat pushed a commit to ryancat/react-native that referenced this pull request Aug 31, 2023
…oid race (facebook#38671)

Summary:
Pull Request resolved: facebook#38671

Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the  `mShouldStop` flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees `stop` would queue logic that removes the frame loop callback, and a later `start` would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Reviewed By: hoxyq

Differential Revision: D47849848

fbshipit-source-id: 5523c7a4499d48abbe3f80e2cfc1ebed00b07f93
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

ryancat pushed a commit to ryancat/react-native that referenced this pull request Sep 8, 2023
…oid race (facebook#38671)

Summary:

Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the  `mShouldStop` flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees `stop` would queue logic that removes the frame loop callback, and a later `start` would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Reviewed By: hoxyq

Differential Revision: D47849848
…oid race (facebook#38671)

Summary:

Fix a race condition when we unmount and mount a view using FpsView too frequently. In this case, the frame loop callback didn't get a chance to unset the  `mShouldStop` flag, causing the old frame loop continues to run unexpectedly.

The fix here guarantees `stop` would queue logic that removes the frame loop callback, and a later `start` would queue logic that attaches a new frame loop callback. Since both of them happens on UI thread, they are in sync.

Changelog:
[Android][Fixed] - Fix a race with FpsView on using FpsDebugFrameCallback.

Reviewed By: hoxyq

Differential Revision: D47849848
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D47849848

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

This pull request was successfully merged by Xin Chen in a63b443.

When will my fix make it into a release? | Upcoming Releases

@github-actions github-actions bot added the Merged This PR has been merged. label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants