mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/21296: add ProfilerMarkers.addForDispatchTouchEvent.
This commit is contained in:
parent
49294996e2
commit
9c2e6eee78
@ -19,6 +19,7 @@ import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ActionMode
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewConfiguration
|
||||
import android.view.WindowManager.LayoutParams.FLAG_SECURE
|
||||
import androidx.annotation.CallSuper
|
||||
@ -581,6 +582,11 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
||||
ProfilerMarkers.addForDispatchTouchEvent(components.core.engine.profiler, ev)
|
||||
return super.dispatchTouchEvent(ev)
|
||||
}
|
||||
|
||||
final override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
// Inspired by https://searchfox.org/mozilla-esr68/source/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java#584-613
|
||||
// Android N and Huawei devices have broken onKeyLongPress events for the back button, so we
|
||||
|
@ -5,6 +5,7 @@
|
||||
package org.mozilla.fenix.perf
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.core.view.doOnPreDraw
|
||||
@ -28,6 +29,20 @@ object ProfilerMarkers {
|
||||
profiler?.addMarker("onPreDraw", "expected first frame via HomeActivity.onStart")
|
||||
}
|
||||
}
|
||||
|
||||
fun addForDispatchTouchEvent(profiler: Profiler?, ev: MotionEvent?) {
|
||||
// We only run this if the profiler is active to minimize any possible delay on touch events.
|
||||
if (profiler?.isProfilerActive() == true) {
|
||||
// We only do this subset because 1) other actions like MOVE may be spammy and 2) doing
|
||||
// a generic ev?.action::class.simpleName may be too expensive for dispatchTouchEvent.
|
||||
val detailText = when (ev?.action) {
|
||||
MotionEvent.ACTION_DOWN -> "ACTION_DOWN"
|
||||
MotionEvent.ACTION_UP -> "ACTION_UP"
|
||||
else -> return
|
||||
}
|
||||
profiler.addMarker("dispatchTouchEvent", detailText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user