mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
PerfMonitor - Fix enable/disable states (#53957)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8bc133c6c1
commit
456e01bf3f
+10
-3
@@ -20,18 +20,25 @@ internal class PerfMonitorOverlayManager(
|
||||
|
||||
/** Enable the Perf Monitor overlay. */
|
||||
fun enable() {
|
||||
if (enabled) {
|
||||
return
|
||||
}
|
||||
|
||||
enabled = true
|
||||
UiThreadUtil.runOnUiThread {
|
||||
val context = devHelper.currentActivity ?: return@runOnUiThread
|
||||
view = PerfMonitorOverlayView(context, ::handleRecordingButtonPress)
|
||||
if (view == null) {
|
||||
view = PerfMonitorOverlayView(context, ::handleRecordingButtonPress)
|
||||
}
|
||||
view?.show()
|
||||
}
|
||||
}
|
||||
|
||||
/** Disable the Perf Monitor overlay. Will remain hidden when updates are received. */
|
||||
fun disable() {
|
||||
UiThreadUtil.runOnUiThread { view?.hide() }
|
||||
view = null
|
||||
enabled = false
|
||||
|
||||
UiThreadUtil.runOnUiThread { view?.hide() }
|
||||
}
|
||||
|
||||
/** Start background trace recording. */
|
||||
|
||||
Reference in New Issue
Block a user