Skip to content

Commit 456e01b

Browse files
sbuggayfacebook-github-bot
authored andcommitted
PerfMonitor - Fix enable/disable states (#53957)
Summary: Pull Request resolved: #53957 There are cases where the overlay can get enabled multiple times, creating more than one view. This change no-ops enabling if the overlay is already enabled and just uses enable/disable for showing/hiding the view. {F1982272836} Changelog: [Internal] Reviewed By: hoxyq Differential Revision: D83275253 fbshipit-source-id: 4b468171a582e134071875f718c66d1659d67782
1 parent 8bc133c commit 456e01b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayManager.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,25 @@ internal class PerfMonitorOverlayManager(
2020

2121
/** Enable the Perf Monitor overlay. */
2222
fun enable() {
23+
if (enabled) {
24+
return
25+
}
26+
2327
enabled = true
2428
UiThreadUtil.runOnUiThread {
2529
val context = devHelper.currentActivity ?: return@runOnUiThread
26-
view = PerfMonitorOverlayView(context, ::handleRecordingButtonPress)
30+
if (view == null) {
31+
view = PerfMonitorOverlayView(context, ::handleRecordingButtonPress)
32+
}
33+
view?.show()
2734
}
2835
}
2936

3037
/** Disable the Perf Monitor overlay. Will remain hidden when updates are received. */
3138
fun disable() {
32-
UiThreadUtil.runOnUiThread { view?.hide() }
33-
view = null
3439
enabled = false
40+
41+
UiThreadUtil.runOnUiThread { view?.hide() }
3542
}
3643

3744
/** Start background trace recording. */

0 commit comments

Comments
 (0)