Skip to content
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

App freezes when GPU is disabled while the app is running #124194

Open
temirlanzhangazy opened this issue Apr 5, 2023 · 17 comments
Open

App freezes when GPU is disabled while the app is running #124194

temirlanzhangazy opened this issue Apr 5, 2023 · 17 comments
Labels
a: desktop Running on desktop c: crash Stack traces logged to the console engine flutter/engine repository. See also e: labels. found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team triaged-windows Triaged by the Windows platform team

Comments

@temirlanzhangazy
Copy link

temirlanzhangazy commented Apr 5, 2023

While running Flutter app on a desktop, if you disable GPU, (even if enable it again) flutter app will freeze.

Expected results:
Flutter Desktop App would switch GPU or turn on software rendering.

Actual results:
Rendering has stopped. The application is frozen.

Example:
Windows app built with Flutter is set to launch on startup, but some users are experiencing issues where their GPU is not fully enabled yet, causing the app to freeze or crash. To address this, a third-party app was developed that delays the launch of the Flutter app until the GPU is fully enabled. Also when some GPU functionalities like Nvidia G-Sync were turned on AFTER the flutter app was launched, app freezes too.

flutter doctor -v
[√] Flutter (Channel master, 3.9.0-13.0.pre.4, on Microsoft Windows [Version 10.0.19045.2728], locale
    en-GB)
    • Flutter version 3.9.0-13.0.pre.4 on channel master at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8de2433a4c (2 weeks ago), 2023-03-21 06:58:24 -0400
    • Engine revision e07fb9b5dd
    • Dart version 3.0.0 (build 3.0.0-348.0.dev)
    • DevTools version 2.22.2

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\zhang\AppData\Local\Android\sdk
    • Platform android-33-ext5, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
    • All Android licenses accepted.

[X] Chrome - develop for the web (Cannot find Chrome executable at
    .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33516.290
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)

[√] VS Code (version 1.76.2)
    • VS Code at C:\Users\zhang\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.62.0

[√] Connected device (2 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.2728]
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 111.0.1661.62

[√] Network resources
    • All expected network resources are available.
@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Apr 5, 2023
@exaby73
Copy link
Member

exaby73 commented Apr 5, 2023

Hello @temirlanzhangazy. Are you able to reproduce this issue in debug mode? Are there any stack traces you can provide?

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 5, 2023
@temirlanzhangazy
Copy link
Author

temirlanzhangazy commented Apr 6, 2023

Hello. I tried the same thing in debug mode: same result.
What is interesting:
The app seems to be fully working, all print messages are being created, and Windows cursor is reacting to hover events (pointer cursor on button).

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 6, 2023
@danagbemava-nc
Copy link
Member

Hi @temirlanzhangazy, does this occur with the sample app as well or only with your app?

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 6, 2023
@temirlanzhangazy
Copy link
Author

Yes, this occurs with the sample app too.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 6, 2023
@temirlanzhangazy
Copy link
Author

Flashback.-.Apr.6.2023.13_44_20.mp4

Here is the sample app.
When I disable the GPU driver, all apps will switch GPU or turn on software rendering. But flutter app's rendering is freezed.

@danagbemava-nc
Copy link
Member

Hi @temirlanzhangazy, if you run the app with the --enable-software-rendering flag, do you still have this issue? Can you also check on the latest version of the master channel to see if the issue is still there?

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 6, 2023
@temirlanzhangazy
Copy link
Author

temirlanzhangazy commented Apr 6, 2023

Yes, issue is the same with --enable-software-rendering flag.
I have the latest version of the master channel.

I noticed these errors after disabling GPU.
2 ERR: SwapChain11.cpp:947 (present): Present failed: the D3D11 device was removed, HRESULT: 0x887A0005
2142 [ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(217)] Could not make the context current to acquire the frame.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 6, 2023
@temirlanzhangazy
Copy link
Author

How can I catch these errors so I can exit my application?

@exaby73
Copy link
Member

exaby73 commented Apr 10, 2023

The error looks to be coming from the engine and not from the framework, so I don't think there is a way to catch these errors. I have a Windows laptop with a dedicated, as well as iGPU, but currently I do not have it with me. I'll try to reproduce this issue with the steps I can see in the video you provided in #124194 (comment) and get back here with my findings

@exaby73
Copy link
Member

exaby73 commented Apr 11, 2023

I can reproduce this issue on Windows 11 on Master (3.10.0-3.0.pre.30). I disabled the iGPU via device manager to reproduce this. I got the same error logs as OP in this instance. Disabling external GPU does not reproduce this.

ERR: SwapChain11.cpp:947 (present): Present failed: the D3D11 device was removed, HRESULT: 0x887A0005
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(217)] Could not make the context current to acquire the frame.
flutter doctor -v (Master)
[!] Flutter (Channel master, 3.10.0-3.0.pre.30, on Microsoft Windows [Version 10.0.22621.1485], locale en-IN)
    • Flutter version 3.10.0-3.0.pre.30 on channel master at C:\Users\Nabeel\fvm\versions\master
    ! The flutter binary is not on your path. Consider adding C:\Users\Nabeel\fvm\versions\master\bin to your path.
    ! Warning: `dart` on your path resolves to C:\tools\dart-sdk\bin\dart.exe, which is not inside your current Flutter SDK checkout at C:\Users\Nabeel\fvm\versions\master. Consider adding C:\Users\Nabeel\fvm\versions\master\bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2cf8502589 (3 hours ago), 2023-04-10 20:21:24 -0700
    • Engine revision 4a7f3f2a1f
    • Dart version 3.0.0 (build 3.0.0-427.0.dev)
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\android-sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Users\Nabeel\programs\android-studio-preview\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9746777)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.0)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33414.496
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2022.1)
    • Android Studio at C:\Users\Nabeel\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\221.6008.13.2211.9619390
    • Flutter plugin version 72.1.2
    • Dart plugin version 221.6103.1
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)

[✓] Android Studio (version 2022.3)
    • Android Studio at C:\Users\Nabeel\programs\android-studio-preview
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9746777)

[✓] VS Code (version 1.77.0)
    • VS Code at C:\Users\Nabeel\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.1485]
    • Chrome (web)      • chrome  • web-javascript • unknown
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 112.0.1722.34

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

@exaby73 exaby73 changed the title [desktop] Auto turn off hardware acceleration, auto switch GPU App freezes when GPU is disabled while the app is running Apr 11, 2023
@exaby73 exaby73 added c: crash Stack traces logged to the console engine flutter/engine repository. See also e: labels. platform-windows Building on or for Windows specifically has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 and removed in triage Presently being triaged by the triage team labels Apr 11, 2023
@loic-sharma loic-sharma added the a: desktop Running on desktop label Apr 11, 2023
@loic-sharma
Copy link
Member

loic-sharma commented Apr 11, 2023

Thank you for reporting this issue!

The Flutter engine accepts render configs at startup and does not support switching between GPU/software rendering at runtime yet.

Windows app built with Flutter is set to launch on startup, but some users are experiencing issues where their GPU is not fully enabled yet, causing the app to freeze or crash

This is surprising. I would expect this to work using software rendering. We might need to update our GPU detection logic to better handle this startup scenario.

Also when some GPU functionalities like Nvidia G-Sync were turned on AFTER the flutter app was launched, app freezes too.

I'm not familiar with this. This sounds like a bug that we'll need to investigate.

@loic-sharma
Copy link
Member

It seems this issue also happens if you update your drivers while a Flutter app is running: #88007

@gspencergoog gspencergoog added the P2 Important issues not at the top of the work list label Apr 13, 2023
@jnschulze
Copy link
Member

jnschulze commented Apr 17, 2023

I've also seen this on customer devices:
When putting a machine to sleep while a Flutter app is running and waking it up afterwards, the app sometimes hangs. A debug build revealed that those devices had lost the context ("Could not make the context current to acquire the frame").

AngleSurfaceManager::MakeCurrent (see https://github.com/flutter/engine/blob/360ca05311c8fafe73333ca2c58dfecf9b701d40/shell/platform/windows/angle_surface_manager.cc#L277) should recreate the context if eglMakeCurrent() returns EGL_FALSE and eglGetError() == EGL_CONTEXT_LOST

Related: #111151

@21pages
Copy link

21pages commented Jan 21, 2024

ERR: SwapChain11.cpp:947 (present): Present failed: the D3D11 device was removed, HRESULT: 0x00000000
ERR: SwapChain11.cpp:947 (present): Present failed: the D3D11 device was removed, HRESULT: 0x00000000
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
flutter: Saving frame: null: 799.0/600.0, offset:2525.0/102.0, isMaximized:false, isFullscreen:false
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
[ERROR:flutter/shell/gpu/gpu_surface_gl_skia.cc(218)] Could not make the context current to acquire the frame.
Lost connection to device.

@jonodav
Copy link

jonodav commented Mar 27, 2024

Just wanted to chime in and add another user to the pile. I believe I've been experiencing this same issue, predominately when windows restores from a sleep state. I've noted the cursor still responds to click targets and the app is still functioning underneath however the UI is completely frozen. Resizing the window leaves blank space.

I've not experienced this in my development environment with a AMD GPU, only production, which runs on Intel integrated graphics. This has a significant effect on my applications viability as at current there is no way to appropriately handle the bug.

Edit 19/4/24: I added a wakelock to my app to see if that has any effect on the renderer crashing. It does not seem to prevent anything, it still sporadically breaks with the app still running underneath leaving the user to manually restart the app.

@annd22
Copy link

annd22 commented Apr 24, 2024

Is there any update for this 😭

@cbracken cbracken added team-windows Owned by the Windows platform team and removed team-desktop labels Jun 6, 2024
@flutter-triage-bot
Copy link

The triaged-desktop label is irrelevant if there is no team-desktop label or fyi-desktop label.

@cbracken cbracken added the triaged-windows Triaged by the Windows platform team label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop c: crash Stack traces logged to the console engine flutter/engine repository. See also e: labels. found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team triaged-windows Triaged by the Windows platform team
Projects
None yet
Development

No branches or pull requests

10 participants