-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime-Configurable Engine Options (Similar to FieldTrial / RemoteConfig) #160902
Comments
it doesn't seem possible, see comment below |
@bc-lee |
Apologies for posting prematurely before fully investigating the issue. After further digging, I managed to dynamically control the use of Impeller at runtime, particularly with Firebase Remote Config. Here's the code snippet I used for testing. (Tested in Flutter 3.27.1) I'll be closing this issue now. package com.example.sampleapp
import android.os.Bundle
import android.util.Log
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
import com.google.firebase.ktx.Firebase
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterShellArgs
class MainActivity : FlutterActivity() {
private lateinit var remoteConfig: FirebaseRemoteConfig
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
remoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 3600
}
remoteConfig.setConfigSettingsAsync(configSettings).addOnCompleteListener { task ->
if (task.isSuccessful) {
remoteConfig.fetchAndActivate().addOnCompleteListener { fetchTask ->
if (!fetchTask.isSuccessful) {
Log.e(TAG, "Failed to fetch and activate remote config")
} else {
Log.d(TAG, "Remote config fetched and activated")
}
}
} else {
Log.e(TAG, "Failed to set config settings")
}
}
}
override fun getFlutterShellArgs(): FlutterShellArgs {
val args = mutableListOf<String>()
val useImpeller = try {
// AndroidUseImpeller is a Remote Config parameter that can be used to enable or disable Impeller.
remoteConfig.getBoolean("AndroidUseImpeller")
} catch (e: Exception) {
false
}
if (useImpeller) {
args.add(FlutterShellArgs.ARG_ENABLE_IMPELLER)
} else {
args.add(FlutterShellArgs.ARG_DISABLE_IMPELLER)
}
return FlutterShellArgs(args)
}
companion object {
private const val TAG = "MainActivity"
}
} |
Use case
From what I understand, the Flutter engine currently lacks runtime-configurable options, leaving developers with little flexibility once the engine is initialized. While this works for many use cases, recent developments—such as the introduction of Impeller on Android—have exposed significant issues on specific devices. The diversity of Android hardware and inconsistent Vulkan driver quality further complicate the situation.
Flutter provides limited build-time customization (e.g.,
<meta-data>
in the Android manifest to enable or disable Impeller). However, changing these settings requires a full rebuild and re-deployment. This process is not only time-consuming—especially on iOS, where app review delays are common—but also reduces stakeholders’ confidence in Flutter’s readiness for production environments.Proposal
Introduce runtime-configurable engine options to provide developers with greater flexibility in managing critical settings. For example, developers could dynamically switch between the legacy Skia renderer and Impeller without requiring a rebuild. If implementing separate controls for each option proves challenging, consider adopting Chromium’s approach using runtime-configurable features or field trials (e.g.,
Flutter-Use-Impeller/Disabled/
). This system enables defining and adjusting options in a centralized, declarative format at runtime.By enabling runtime-configurable engine options, Flutter developers could:
This change would significantly enhance Flutter’s appeal as a production-ready framework by addressing one of the most critical pain points for developers working in diverse hardware environments.
The text was updated successfully, but these errors were encountered: