You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Force Android emulator to use GPU hardware acceleration #2319
On my machine emulator seems to be running without GPU acceleration when launched from Visual Studio Code or AVD event when I configure hardware acceleration as follows:
But I when I launch it from command line with -gpu host argument rendering performance increases dramatically.
By default, the emulator decides whether to use hardware or software graphics acceleration based on your computer setup. If your GPU hardware and drivers are compatible, the emulator uses the GPU. Otherwise, the emulator uses software acceleration (using your computer's CPU) to simulate GPU processing.
If you start the emulator from the command line, you can also override the graphics acceleration setting in the AVD for that virtual device instance.
I am not sure if this is some issue with Android emulators / AVD on my machine or it is something that could help other users too and might be implemented in Dart Code?..
Yep, Flutter does the emulator launching. If it's a common need to force this, it may make sense to have a switch in Flutter (which could be passed through from DartVS Code).
@DanTup, thank you for clarifications. Currently I am not sure if anybody else observes that launching emulators when using -gpu host flag from console significantly speeds up emulator: this is only my observation which might be incorrect.
So being not sure if it 's a common need to force GPU acceleration from console I closed the issue.
@DanTup, actually in my observations I see performance improvement only in rendering, not startup. So when I launch emulator from console with -gpu host I see that animations are smoother than when I launch from VSCode/Android Studio.
But as I said - I am not sure if this is happening only on my machine and if anyone else is able to reproduce such behavior, so I decided to close this issue...
There's an open issue at #1553 that might provide another way to do this (if implemented) that would let you override the command executed to launch an emulator (so you could replace it with emulator -avd foo -gpu host).
I've implemented it and added an example of how it works to #1553. I'll ship a beta version for testing later in the month if you want to try it out before it ships in a release.
@roman-petrov Currently I am using a Dell laptop , with 2 GPUs, an onboard GPU and an AMD Radeon R5 M435. When I run Android Studio + emulator (installed running on hardware) and I check that it only uses the onboard GPU . How to use AMD for running emulator .
This is the closed issue in Dart Code plugin for Visual Studio Code but you asking just a general question about Android emulators. So this is not the right place to ask such questions and I am not an expert in Android emulators, please read the official documentation about how to use them.
Anyways, this issue (if it exists) is 100% not connected to Dart-Code, it might be related to Android tooling or even my machine configuration.
That's why I decided to close the issue:) @DanTup, thank you very much for all your help!
I just experienced the same thing as you (slow emulator when running from flutter vscode) in Linux, and your information running emulator from that command really help me boost my emulator performance, i still haven't found a fix solution. But anyway thanks for that!
I dont know if you already fix this issue, but the work oround I used is:
1.I changed the name from emulator to emulator-bin
2. And created a bash script with $EMULATOR_PATH/emulator $*
Activity
roman-petrov commentedon Mar 27, 2020
I decided to close this issue since I figured out that
Dart Codelaunches Flutter emulator throughflutter emulators --launch <emulator id>so feature I suggested should be available in
Flutterfirst...DanTup commentedon Mar 30, 2020
Yep, Flutter does the emulator launching. If it's a common need to force this, it may make sense to have a switch in Flutter (which could be passed through from DartVS Code).
The code that launches is here:
https://github.com/flutter/flutter/blob/ba57ea09d17a30c05d6771cffdb6d10250b2f359/packages/flutter_tools/lib/src/android/android_emulator.dart#L56-L59
And that gets called from here:
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/emulators.dart#L72
If there's a switch you can add on to
emulator -avd footo control the hardware acceleration, it might not be too tricky to pass a flag through there.roman-petrov commentedon Mar 30, 2020
@DanTup, thank you for clarifications. Currently I am not sure if anybody else observes that launching emulators when using
-gpu hostflag from console significantly speeds up emulator: this is only my observation which might be incorrect.So being not sure if it 's a common need to force GPU acceleration from console I closed the issue.
DanTup commentedon Apr 13, 2020
How significant is the difference you see, and on what OS (both host, and which Android version)?
I tested with a Pixel emulator on MacBook Pro and see about 14 seconds (cold boot) with and without the flag.
Based on the info at https://developer.android.com/studio/run/emulator-acceleration#accel-graphics it seems like this my default based on the emulator image - so you may be able to set this in Android Studio and then in future it'll use that setting without needing the flag:
roman-petrov commentedon Apr 13, 2020
@DanTup, actually in my observations I see performance improvement only in rendering, not startup. So when I launch emulator from console with
-gpu hostI see that animations are smoother than when I launch from VSCode/Android Studio.But as I said - I am not sure if this is happening only on my machine and if anyone else is able to reproduce such behavior, so I decided to close this issue...
DanTup commentedon Apr 13, 2020
Oh sorry, I misunderstood your comment and thought you were talking about the launch performance (I did think that sounded a bit strange!).
If you change the emulator settings using the dropdown shown above, does that resolve the issue when launching from VS Code?
roman-petrov commentedon Apr 14, 2020
Actually, I tried setting
Graphicsdropdown to bothAutomaticandHardware - GLES 2.0and launching emulator fromAVD ManagerStill my observations are that rendering is better/smoother if I launch emulator using command line using console command
C:\Users\<my username>\AppData\Local\Android\Sdk\emulator\emulator.exe -avd MyAvd -gpu hostAnyways, this issue (if it exists) is 100% not connected to
Dart-Code, it might be related to Android tooling or even my machine configuration.That's why I decided to close the issue:) @DanTup, thank you very much for all your help!
DanTup commentedon Apr 14, 2020
Ah, I guess that menu doesn't do the same.
There's an open issue at #1553 that might provide another way to do this (if implemented) that would let you override the command executed to launch an emulator (so you could replace it with
emulator -avd foo -gpu host).roman-petrov commentedon Apr 15, 2020
Thank you! Actually I am already following the issue you mentioned and looking forward to see it resolved.
DanTup commentedon Apr 15, 2020
I've implemented it and added an example of how it works to #1553. I'll ship a beta version for testing later in the month if you want to try it out before it ships in a release.
roman-petrov commentedon Apr 15, 2020
Thank you very much for all your efforts! I will definitely try this feature after beta is shipped!
doducthangcvp291 commentedon Nov 2, 2021
@roman-petrov Currently I am using a Dell laptop , with 2 GPUs, an onboard GPU and an AMD Radeon R5 M435. When I run Android Studio + emulator (installed running on hardware) and I check that it only uses the onboard GPU . How to use AMD for running emulator .
roman-petrov commentedon Nov 3, 2021
@doducthangcvp291, I don't have any idea how to answer your question. All these issue details are listed above, I have nothing to add.
doducthangcvp291 commentedon Nov 3, 2021
I just use command C:\Users<my username>\AppData\Local\Android\Sdk\emulator\emulator.exe -avd MyAvd -gpu host , right ?
roman-petrov commentedon Nov 3, 2021
This is the closed issue in Dart Code plugin for Visual Studio Code but you asking just a general question about Android emulators. So this is not the right place to ask such questions and I am not an expert in Android emulators, please read the official documentation about how to use them.
gopelkujo commentedon Oct 6, 2022
I just experienced the same thing as you (slow emulator when running from flutter vscode) in Linux, and your information running emulator from that command really help me boost my emulator performance, i still haven't found a fix solution. But anyway thanks for that!
pedrohms commentedon Oct 27, 2022
I dont know if you already fix this issue, but the work oround I used is:$EMULATOR_PATH/emulator $ *
1.I changed the name from emulator to emulator-bin
2. And created a bash script with
this fixed my problem
BiEchi commentedon Mar 13, 2024
Seems like
-gpu hostraises such error. Is there a way to solve it?WARNING | Your GPU drivers may have a bug. If you experience graphical issues, please consider switching to software rendering.
library_mode host gpu mode host
Initializing hardware OpenGLES emulation supportandroid_startOpenglesRenderer: gpu infoI0313 22:50:00.118760 27958 HealthMonitor.cpp:279] HealthMonitor disabled.
GlxEnginegetDefaultDisplay: Failed to open display 0. DISPLAY: [(null)]
E0313 22:50:00.119003 27958 EmulationGl.cpp:233] Failed to get EGL display.
E0313 22:50:00.119014 27958 FrameBuffer.cpp:333] Failed to initialize GL emulation.
E0313 22:50:00.119046 27958 RendererImpl.cpp:141] Could not initialize emulated framebuffer