Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Set up macro benchmarking for the Android editor

Fredia Huya-Kouadio608f24c0982d
diff --git a/platform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt b/platform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt
index 383154e75e9..d07f292bae4 100644
--- a/platform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt
+++ b/platform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt
@@ -43,6 +43,7 @@ import org.godotengine.godot.GodotActivity.Companion.EXTRA_COMMAND_LINE_PARAMS
import org.godotengine.godot.plugin.GodotPluginRegistry
import org.junit.Test
import org.junit.runner.RunWith
+import kotlin.collections.contentEquals
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
@@ -61,6 +62,7 @@ class GodotAppTest {
private const val GODOT_APP_CLASS_NAME = "com.godot.game.GodotApp"
private val TEST_COMMAND_LINE_PARAMS = arrayOf("This is a test")
+ private val VULKAN_RENDERER_COMMAND_LINE_PARAMS = arrayOf("--rendering-method","mobile")
}
private fun getTestPlugin(): GodotAppInstrumentedTestPlugin? {
@@ -195,6 +197,32 @@ class GodotAppTest {
}
}
+ /**
+ * Test that launching using the Vulkan renderer doesn't crash the app.
+ */
+ @Test
+ fun testVulkanGodotAppLaunch() {
+ val appIntent = Intent().apply {
+ component = ComponentName(BuildConfig.APPLICATION_ID, GODOT_APP_CLASS_NAME)
+ putExtra(EXTRA_COMMAND_LINE_PARAMS, VULKAN_RENDERER_COMMAND_LINE_PARAMS)
+ }
+ ActivityScenario.launch<GodotApp>(appIntent).use { scenario ->
+ val testPlugin = getTestPlugin()
+ assertNotNull(testPlugin)
+
+ Log.d(TAG, "Waiting for the Godot main loop to start...")
+ testPlugin.waitForGodotMainLoopStarted()
+
+ scenario.onActivity { activity ->
+ assertEquals(activity.intent.component?.className, GODOT_APP_CLASS_NAME)
+
+ val commandLineParams = activity.intent.getStringArrayExtra(EXTRA_COMMAND_LINE_PARAMS)
+ assertNotNull(commandLineParams)
+ assertTrue(commandLineParams.contentEquals(VULKAN_RENDERER_COMMAND_LINE_PARAMS))
+ }
+ }
+ }
+
/**
* Validate that the back press does not quit the game when 'quit_on_go_back' is disabled.
*/
diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle
index fcbb102851c..8f299420b16 100644
--- a/platform/android/java/editor/build.gradle
+++ b/platform/android/java/editor/build.gradle
@@ -137,6 +137,15 @@ android {
signingConfig signingConfigs.debug
}
+ benchmark {
+ initWith release
+ applicationIdSuffix ".benchmark"
+ manifestPlaceholders += [editorBuildSuffix: " (benchmark)"]
+ signingConfig signingConfigs.debug
+ matchingFallbacks = ['release']
+ debuggable false
+ }
+
release {
if (hasReleaseSigningConfigs()) {
signingConfig signingConfigs.release
@@ -210,6 +219,7 @@ dependencies {
implementation "org.bouncycastle:bcprov-jdk15to18:1.78"
implementation "org.khronos.openxr:openxr_loader_for_android:$versions.openxrLoaderVersion"
+ implementation "androidx.profileinstaller:profileinstaller:1.4.1"
// Android XR dependencies
androidImplementation "org.godotengine:godot-openxr-vendors-androidxr:$versions.openxrVendorsVersion"
diff --git a/platform/android/java/editor/macrobenchmark/.gitignore b/platform/android/java/editor/macrobenchmark/.gitignore
new file mode 100644
index 00000000000..796b96d1c40
--- /dev/null
+++ b/platform/android/java/editor/macrobenchmark/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/platform/android/java/editor/macrobenchmark/build.gradle b/platform/android/java/editor/macrobenchmark/build.gradle
new file mode 100644
index 00000000000..214d5fa2691
--- /dev/null
+++ b/platform/android/java/editor/macrobenchmark/build.gradle
@@ -0,0 +1,56 @@
+plugins {
+ id 'com.android.test'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'org.godotengine.editor.v4.macrobenchmark'
+ compileSdk versions.compileSdk
+
+ compileOptions {
+ sourceCompatibility versions.javaVersion
+ targetCompatibility versions.javaVersion
+ }
+
+ kotlinOptions {
+ jvmTarget = versions.javaVersion
+ }
+
+ defaultConfig {
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
+ missingDimensionStrategy 'products', 'editor'
+ missingDimensionStrategy 'android_distribution', 'android'
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = 'EMULATOR'
+ }
+
+ buildTypes {
+ // This benchmark buildType is used for benchmarking, and should function like your
+ // release build (for example, with minification on). It's signed with a debug key
+ // for easy local/CI testing.
+ benchmark {
+ debuggable = true
+ signingConfig = debug.signingConfig
+ matchingFallbacks = ["release"]
+ }
+ }
+
+ targetProjectPath = ":editor"
+ experimentalProperties["android.experimental.self-instrumenting"] = true
+}
+
+dependencies {
+ implementation 'androidx.benchmark:benchmark-macro-junit4:1.4.1'
+ implementation 'androidx.test.espresso:espresso-core:3.7.0'
+ implementation 'androidx.test.ext:junit:1.3.0'
+ implementation 'androidx.test.uiautomator:uiautomator:2.4.0'
+ implementation 'androidx.test:rules:1.7.0'
+}
+
+androidComponents {
+ beforeVariants(selector().all()) {
+ enable = buildType == "benchmark"
+ }
+}
diff --git a/platform/android/java/editor/macrobenchmark/src/main/AndroidManifest.xml b/platform/android/java/editor/macrobenchmark/src/main/AndroidManifest.xml
new file mode 100644
index 00000000000..cc947c56799
--- /dev/null
+++ b/platform/android/java/editor/macrobenchmark/src/main/AndroidManifest.xml
@@ -0,0 +1 @@
+<manifest />
diff --git a/platform/android/java/editor/macrobenchmark/src/main/java/org/godotengine/editor/v4/macrobenchmark/EditorBenchmarks.kt b/platform/android/java/editor/macrobenchmark/src/main/java/org/godotengine/editor/v4/macrobenchmark/EditorBenchmarks.kt
new file mode 100644
index 00000000000..4d788ba6408
--- /dev/null
+++ b/platform/android/java/editor/macrobenchmark/src/main/java/org/godotengine/editor/v4/macrobenchmark/EditorBenchmarks.kt
@@ -0,0 +1,180 @@
+/**************************************************************************/
+/* EditorBenchmarks.kt */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+
+package org.godotengine.editor.v4.macrobenchmark
+
+import android.Manifest
+import android.util.Log
+import androidx.benchmark.macro.ExperimentalMetricApi
+import androidx.benchmark.macro.FrameTimingGfxInfoMetric
+import androidx.benchmark.macro.MemoryUsageMetric
+import androidx.benchmark.macro.StartupMode
+import androidx.benchmark.macro.StartupTimingMetric
+import androidx.benchmark.macro.junit4.MacrobenchmarkRule
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.rule.GrantPermissionRule
+import androidx.test.uiautomator.By
+import androidx.test.uiautomator.StaleObjectException
+import androidx.test.uiautomator.Until
+import androidx.test.uiautomator.uiAutomator
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Set of editor macro benchmarks.
+ *
+ * Before running, switch the editor's active build variant to 'benchmark'
+ */
+@RunWith(AndroidJUnit4::class)
+class EditorBenchmarks {
+
+ companion object {
+ private val TAG = EditorBenchmarks::class.java.simpleName
+
+ private const val PACKAGE_NAME = "org.godotengine.editor.v4.benchmark"
+ private const val ITERATION_COUNT = 5
+ private const val EXTRA_LOAD_EMPTY_BENCHMARK_PROJECT = "load_empty_benchmark_project"
+ private const val EXTRA_BENCHMARK_RENDERING_METHOD = "benchmark_rendering_method"
+
+ private const val MOBILE_RENDERING_METHOD = "mobile"
+ private const val GL_COMPATIBILITY_RENDERING_METHOD = "gl_compatibility"
+ }
+
+ @get:Rule
+ val benchmarkRule = MacrobenchmarkRule()
+ @get:Rule
+ val grantPermissionRule = GrantPermissionRule.grant(
+ Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE)
+
+ /**
+ * Navigates to the device's home screen, and launches the Project Manager.
+ */
+ @OptIn(ExperimentalMetricApi::class)
+ @Test
+ fun startupProjectManagerUsingOpenGL() = benchmarkRule.measureRepeated(
+ packageName = PACKAGE_NAME,
+ metrics = listOf(
+ StartupTimingMetric(),
+ MemoryUsageMetric(MemoryUsageMetric.Mode.Max),
+ FrameTimingGfxInfoMetric(),
+ ),
+ iterations = ITERATION_COUNT,
+ startupMode = StartupMode.COLD
+ ) {
+ pressHome()
+ startActivityAndWait { intent ->
+ intent.putExtra(EXTRA_BENCHMARK_RENDERING_METHOD, GL_COMPATIBILITY_RENDERING_METHOD)
+ }
+ }
+
+ /**
+ * Navigates to the device's home screen, and launches the Project Manager using the Vulkan renderer.
+ */
+ @OptIn(ExperimentalMetricApi::class)
+ @Test
+ fun startupProjectManagerUsingVulkan() = benchmarkRule.measureRepeated(
+ packageName = PACKAGE_NAME,
+ metrics = listOf(
+ StartupTimingMetric(),
+ MemoryUsageMetric(MemoryUsageMetric.Mode.Max),
+ FrameTimingGfxInfoMetric(),
+ ),
+ iterations = ITERATION_COUNT,
+ startupMode = StartupMode.COLD
+ ) {
+ pressHome()
+ startActivityAndWait { intent ->
+ intent.putExtra(EXTRA_BENCHMARK_RENDERING_METHOD, MOBILE_RENDERING_METHOD)
+ }
+ }
+
+ /**
+ * Navigates to the device's home screen, launches the editor and loads an empty project.
+ */
+ @OptIn(ExperimentalMetricApi::class)
+ @Test
+ fun startupEditorWindowUsingOpenGL() = benchmarkRule.measureRepeated(
+ packageName = PACKAGE_NAME,
+ metrics = listOf(
+ StartupTimingMetric(),
+ MemoryUsageMetric(MemoryUsageMetric.Mode.Max),
+ FrameTimingGfxInfoMetric(),
+ ),
+ iterations = ITERATION_COUNT,
+ startupMode = StartupMode.COLD,
+ ) {
+ pressHome()
+ startActivityAndWait { intent ->
+ intent.putExtra(EXTRA_LOAD_EMPTY_BENCHMARK_PROJECT, true)
+ intent.putExtra(EXTRA_BENCHMARK_RENDERING_METHOD, GL_COMPATIBILITY_RENDERING_METHOD)
+ }
+
+ waitForEditorLoadingIndicator()
+ }
+
+ /**
+ * Navigates to the device's home screen, launches the editor and loads an empty project using the Vulkan renderer.
+ */
+ @OptIn(ExperimentalMetricApi::class)
+ @Test
+ fun startupEditorWindowUsingVulkan() = benchmarkRule.measureRepeated(
+ packageName = PACKAGE_NAME,
+ metrics = listOf(
+ StartupTimingMetric(),
+ MemoryUsageMetric(MemoryUsageMetric.Mode.Max),
+ FrameTimingGfxInfoMetric(),
+ ),
+ iterations = ITERATION_COUNT,
+ startupMode = StartupMode.COLD,
+ ) {
+ pressHome()
+ startActivityAndWait { intent ->
+ intent.putExtra(EXTRA_LOAD_EMPTY_BENCHMARK_PROJECT, true)
+ intent.putExtra(EXTRA_BENCHMARK_RENDERING_METHOD, MOBILE_RENDERING_METHOD)
+ }
+
+ waitForEditorLoadingIndicator()
+ }
+
+ private fun waitForEditorLoadingIndicator() {
+ uiAutomator {
+ try {
+ val selector = By.res("$PACKAGE_NAME:id/editor_loading_indicator")
+ val editorLoadingIndicator = device.findObject(selector)
+ editorLoadingIndicator?.wait(Until.gone(selector), 60_000L)
+ } catch (e: StaleObjectException) {
+ Log.w(TAG, "Error while waiting for editor loading indicator.", e)
+ }
+ }
+ }
+}
diff --git a/platform/android/java/editor/src/androidTest/java/org/godotengine/editor/GodotEditorTest.kt b/platform/android/java/editor/src/androidTest/java/org/godotengine/editor/GodotEditorTest.kt
index c421c21d5a2..59af08d5afb 100644
--- a/platform/android/java/editor/src/androidTest/java/org/godotengine/editor/GodotEditorTest.kt
+++ b/platform/android/java/editor/src/androidTest/java/org/godotengine/editor/GodotEditorTest.kt
@@ -51,6 +51,9 @@ class GodotEditorTest {
private val TAG = GodotEditorTest::class.simpleName
private val TEST_COMMAND_LINE_PARAMS = arrayOf("This is a test")
+ private val PM_LAUNCH_COMMAND_LINE_PARAMS = arrayOf("--project-manager")
+ private val PM_VULKAN_LAUNCH_COMMAND_LINE_PARAMS = PM_LAUNCH_COMMAND_LINE_PARAMS + arrayOf("--rendering-method", "mobile")
+
private const val PROJECT_MANAGER_CLASS_NAME = "org.godotengine.editor.ProjectManager"
private const val GODOT_EDITOR_CLASS_NAME = "org.godotengine.editor.GodotEditor"
}
@@ -114,4 +117,24 @@ class GodotEditorTest {
}
}
}
+
+ /**
+ * Check that the project manager can launch using vulkan (Forward mobile) without crashing.
+ */
+ @Test
+ fun testVulkanProjectManagerLaunch() {
+ val godotEditorIntent = Intent().apply {
+ component = ComponentName(BuildConfig.APPLICATION_ID, GODOT_EDITOR_CLASS_NAME)
+ putExtra(EXTRA_COMMAND_LINE_PARAMS, PM_VULKAN_LAUNCH_COMMAND_LINE_PARAMS)
+ }
+ ActivityScenario.launch<GodotEditor>(godotEditorIntent).use { scenario ->
+ scenario.onActivity { activity ->
+ assertEquals(activity.intent.component?.className, GODOT_EDITOR_CLASS_NAME)
+
+ val commandLineParams = activity.intent.getStringArrayExtra(EXTRA_COMMAND_LINE_PARAMS)
+ assertNotNull(commandLineParams)
+ assertTrue(commandLineParams.contentEquals(PM_VULKAN_LAUNCH_COMMAND_LINE_PARAMS))
+ }
+ }
+ }
}
diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt
index 02b659fd804..dd408971a53 100644
--- a/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt
+++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt
@@ -98,6 +98,10 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
internal const val EXTRA_IS_GAME_EMBEDDED = "is_game_embedded"
internal const val EXTRA_IS_GAME_RUNNING = "is_game_running"
+ // Benchmarking extras.
+ private const val EXTRA_LOAD_EMPTY_BENCHMARK_PROJECT = "load_empty_benchmark_project"
+ private const val EXTRA_BENCHMARK_RENDERING_METHOD = "benchmark_rendering_method"
+
// Command line arguments.
private const val FULLSCREEN_ARG = "--fullscreen"
private const val FULLSCREEN_ARG_SHORT = "-f"
@@ -173,11 +177,21 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
private const val PREF_KEY_DONT_SHOW_GAME_RESUME_HINT = "pref_key_dont_show_game_resume_hint"
@JvmStatic
- fun isRunningInInstrumentation(): Boolean {
+ fun isRunningInInstrumentationOrUserTestHarness(): Boolean {
+ // Check if running in user test harness.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && ActivityManager.isRunningInUserTestHarness()) {
+ return true
+ }
+
if (BuildConfig.BUILD_TYPE == "release") {
return false
}
+ if (BuildConfig.BUILD_TYPE == "benchmark") {
+ return true
+ }
+
+ // Check if running in instrumentation.
return try {
Class.forName("org.godotengine.editor.GodotEditorTest")
true
@@ -256,6 +270,10 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
return mutableSetOf()
}
+ override fun shouldSanitizeLaunchIntent(): Boolean {
+ return BuildConfig.BUILD_TYPE == "release" || (isRunningInInstrumentationOrUserTestHarness() && BuildConfig.BUILD_TYPE != "benchmark")
+ }
+
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
@@ -266,8 +284,7 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
// Skip permissions request if running in a device farm (e.g. firebase test lab) or if requested via the launch
// intent (e.g. instrumentation tests).
- val skipPermissionsRequest = isRunningInInstrumentation() ||
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && ActivityManager.isRunningInUserTestHarness()
+ val skipPermissionsRequest = isRunningInInstrumentationOrUserTestHarness()
if (!skipPermissionsRequest) {
// We exclude certain permissions from the set we request at startup, as they'll be
// requested on demand based on use cases.
@@ -440,6 +457,51 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
}
}
}
+
+ else -> {
+ if (BuildConfig.BUILD_TYPE == "benchmark") {
+ val benchmarkRenderingMethod = intent.getStringExtra(EXTRA_BENCHMARK_RENDERING_METHOD)
+ if (!benchmarkRenderingMethod.isNullOrBlank()) {
+ updatedCommandLineParams.addAll(arrayOf("--rendering-method", benchmarkRenderingMethod))
+ }
+
+ val shouldLoadEmptyBenchmarkProject = intent.getBooleanExtra(EXTRA_LOAD_EMPTY_BENCHMARK_PROJECT, false)
+ if (shouldLoadEmptyBenchmarkProject) {
+ val projectParentDir = getExternalFilesDir(null)
+ if (projectParentDir != null) {
+ val benchmarkDir = File(projectParentDir, "godot_benchmark")
+ try {
+ Log.v(TAG, "Benchmark directory is $benchmarkDir")
+ if (!benchmarkDir.exists()) {
+ if (benchmarkDir.mkdirs()) {
+ Log.v(TAG, "Created benchmark directory: $benchmarkDir")
+ } else {
+ Log.e(TAG, "Unable to create editor benchmark directory")
+ }
+ }
+
+ val projectMetadata = File(benchmarkDir, "project.godot")
+ if (projectMetadata.createNewFile()) {
+ Log.v(TAG, "Created project metadata file: $projectMetadata")
+ }
+
+ // Load the empty project.
+ updatedCommandLineParams.addAll(
+ arrayOf(
+ EDITOR_ARG,
+ PATH_ARG,
+ benchmarkDir.canonicalPath
+ )
+ )
+ } catch(e: Exception) {
+ Log.e(TAG, "Unable to set up benchmark directory", e)
+ }
+ } else {
+ Log.e(TAG, "Unable to access empty benchmark project directory.")
+ }
+ }
+ }
+ }
}
super.handleStartIntent(intent, newLaunch)
@@ -536,7 +598,7 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
if (updatedCommandLineParams.isNotEmpty()) {
params.addAll(updatedCommandLineParams)
}
- if (BuildConfig.BUILD_TYPE == "debug" && !params.contains("--benchmark")) {
+ if ((BuildConfig.BUILD_TYPE == "debug" || BuildConfig.BUILD_TYPE == "benchmark") && !params.contains("--benchmark")) {
params.add("--benchmark")
}
return params
@@ -687,7 +749,7 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
}
override fun onGodotForceQuit(instance: Godot) {
- if (!isRunningInInstrumentation()) {
+ if (!isRunningInInstrumentationOrUserTestHarness()) {
// For instrumented tests, we disable force-quitting to allow the tests to complete successfully, otherwise
// they fail when the process crashes.
super.onGodotForceQuit(instance)
diff --git a/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt
index dba04e36d12..7f9d56a0f84 100644
--- a/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt
@@ -869,6 +869,10 @@ class Godot private constructor(val context: Context) {
magnetometerEnabled.set(java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/sensors/enable_magnetometer")))
runOnHostThread {
+ // Used to report 'Time to full display' metrics.
+ // See https://developer.android.com/topic/performance/vitals/launch-time#time-full for more info.
+ getActivity()?.reportFullyDrawn()
+
registerSensorsIfNeeded()
}
diff --git a/platform/android/java/lib/src/main/java/org/godotengine/godot/GodotActivity.kt b/platform/android/java/lib/src/main/java/org/godotengine/godot/GodotActivity.kt
index 7e3cdc75bc1..68722ee1f2c 100644
--- a/platform/android/java/lib/src/main/java/org/godotengine/godot/GodotActivity.kt
+++ b/platform/android/java/lib/src/main/java/org/godotengine/godot/GodotActivity.kt
@@ -82,7 +82,7 @@ abstract class GodotActivity : FragmentActivity(), GodotHost, PictureInPicturePr
private val gameViewSourceRectHint = Rect()
private val commandLineParams = ArrayList<String>()
- // The bounds of what the aspect ratio can be are between 2.39:1 and 1:2.39 (inclusive).
+ // The bounds of what the aspect ratio can be, are between 2.39:1 and 1:2.39 (inclusive).
// If aspect ratio does not fall between these values, app will crash.
private val minPiPRatio = Rational(100, 239)
private val maxPiPRatio = Rational(239, 100)
@@ -93,13 +93,20 @@ abstract class GodotActivity : FragmentActivity(), GodotHost, PictureInPicturePr
protected var godotFragment: GodotFragment? = null
private set
+ /**
+ * Flag to control whether the launch intent should be sanitized.
+ */
+ protected open fun shouldSanitizeLaunchIntent(): Boolean {
+ return true
+ }
+
/**
* Strip out the command line parameters from intent targeting exported activities.
*/
protected fun sanitizeLaunchIntent(launchIntent: Intent = intent): Intent {
val targetComponent = launchIntent.component ?: componentName
val activityInfo = packageManager.getActivityInfo(targetComponent, 0)
- if (activityInfo.exported) {
+ if (activityInfo.exported && shouldSanitizeLaunchIntent()) {
launchIntent.removeExtra(EXTRA_COMMAND_LINE_PARAMS)
}
@@ -113,7 +120,7 @@ abstract class GodotActivity : FragmentActivity(), GodotHost, PictureInPicturePr
protected fun retrieveCommandLineParamsFromLaunchIntent(launchIntent: Intent = intent): Array<String> {
val targetComponent = launchIntent.component ?: componentName
val activityInfo = packageManager.getActivityInfo(targetComponent, 0)
- if (!activityInfo.exported) {
+ if (!activityInfo.exported || !shouldSanitizeLaunchIntent()) {
val params = launchIntent.getStringArrayExtra(EXTRA_COMMAND_LINE_PARAMS)
return params ?: emptyArray()
}
diff --git a/platform/android/java/lib/src/main/java/org/godotengine/godot/utils/BenchmarkUtils.kt b/platform/android/java/lib/src/main/java/org/godotengine/godot/utils/BenchmarkUtils.kt
index 72d9efefd43..0c9ee54576d 100644
--- a/platform/android/java/lib/src/main/java/org/godotengine/godot/utils/BenchmarkUtils.kt
+++ b/platform/android/java/lib/src/main/java/org/godotengine/godot/utils/BenchmarkUtils.kt
@@ -64,7 +64,7 @@ private val benchmarkTracker = Collections.synchronizedMap(LinkedHashMap<Pair<St
* Note: Only enabled on 'editorDev' build variant.
*/
fun beginBenchmarkMeasure(scope: String, label: String) {
- if (BuildConfig.FLAVOR != "editor" || BuildConfig.BUILD_TYPE != "debug") {
+ if (BuildConfig.FLAVOR != "editor") {
return
}
val key = Pair(scope, label)
@@ -84,7 +84,7 @@ fun beginBenchmarkMeasure(scope: String, label: String) {
*/
@JvmOverloads
fun endBenchmarkMeasure(scope: String, label: String, dumpBenchmark: Boolean = false) {
- if (BuildConfig.FLAVOR != "editor" || BuildConfig.BUILD_TYPE != "debug") {
+ if (BuildConfig.FLAVOR != "editor") {
return
}
val key = Pair(scope, label)
@@ -109,7 +109,7 @@ fun endBenchmarkMeasure(scope: String, label: String, dumpBenchmark: Boolean = f
*/
@JvmOverloads
fun dumpBenchmark(fileAccessHandler: FileAccessHandler? = null, filepath: String? = benchmarkFile) {
- if (BuildConfig.FLAVOR != "editor" || BuildConfig.BUILD_TYPE != "debug") {
+ if (BuildConfig.FLAVOR != "editor") {
return
}
if (!useBenchmark || benchmarkTracker.isEmpty()) {
diff --git a/platform/android/java/settings.gradle b/platform/android/java/settings.gradle
index 809b5f7271d..257bdc41fbd 100644
--- a/platform/android/java/settings.gradle
+++ b/platform/android/java/settings.gradle
@@ -8,6 +8,7 @@ pluginManagement {
id 'com.android.asset-pack' version versions.androidGradlePlugin
id 'org.jetbrains.kotlin.android' version versions.kotlinVersion
id 'io.github.gradle-nexus.publish-plugin' version versions.nexusPublishVersion
+ id 'com.android.test' version versions.androidGradlePlugin
}
repositories {
google()
@@ -27,3 +28,4 @@ include ':editor'
include ':assetPackInstallTime'
project(':assetPackInstallTime').projectDir = file("app/assetPackInstallTime")
+include ':editor:macrobenchmark'
diff --git a/pyproject.toml b/pyproject.toml
index 6b5079737ee..0effff75b43 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -94,6 +94,7 @@ ignore-words-list = [
"mis",
"nd",
"numer",
+ "optin",
"ot",
"outin",
"parm",