From 644e75f1575eeb56ccb0fe5ac11a567b0b8304ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Tue, 16 Apr 2024 22:48:46 +0000 Subject: [PATCH] Bug 1888766 - Decouple the dismiss and profiler state update logics r=mleclair,android-reviewers,gl Previously we had the `profilerViewModel.setProfilerState` call inside the dismiss method. Because of this it was updating the profiler state prematurely when user was pressing "upload profile" button and then returning home quickly. After decoupling the dismiss and setProfilerState calls, now we only update the profiler state once the profiler state changes, which makes sure that profiler states in geckoview and ProfilerViewModel stay in sync. Differential Revision: https://phabricator.services.mozilla.com/D206647 --- .../fenix/perf/ProfilerStopDialogFragment.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/perf/ProfilerStopDialogFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/perf/ProfilerStopDialogFragment.kt index f08b1a6552e2..351860f4422a 100644 --- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/perf/ProfilerStopDialogFragment.kt +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/perf/ProfilerStopDialogFragment.kt @@ -56,9 +56,8 @@ class ProfilerStopDialogFragment : DialogFragment() { } } - override fun dismiss() { + private fun setProfilerState() { profilerViewModel.setProfilerState(requireContext().components.core.engine.profiler!!.isProfilerActive()) - super.dismiss() } @Composable @@ -111,7 +110,14 @@ class ProfilerStopDialogFragment : DialogFragment() { ) { TextButton( onClick = { - requireContext().components.core.engine.profiler?.stopProfiler({}, {}) + requireContext().components.core.engine.profiler?.stopProfiler( + onSuccess = { + setProfilerState() + }, + onError = { + setProfilerState() + }, + ) dismiss() }, ) { @@ -162,6 +168,7 @@ class ProfilerStopDialogFragment : DialogFragment() { resources.getString(message) + extra, Toast.LENGTH_LONG, ).show() + setProfilerState() dismiss() }