Skip to content

fix: suppress deprecated coroutine warning to restore Windows build#3373

Closed
prajakta128 wants to merge 2 commits into
fossasia:mainfrom
prajakta128:fix/windows-cmake-coroutine-warning
Closed

fix: suppress deprecated coroutine warning to restore Windows build#3373
prajakta128 wants to merge 2 commits into
fossasia:mainfrom
prajakta128:fix/windows-cmake-coroutine-warning

Conversation

@prajakta128

Copy link
Copy Markdown
Contributor

Fixes #3246

Problem

The Windows Flutter build fails on the latest Visual Studio because the /await compiler option and <experimental/coroutine> are deprecated by Microsoft and removed in MSVC 14.51+. This breaks the entire Windows CI pipeline and prevents any contributor from building the app on Windows locally.

Root Cause

The permission_handler_windows plugin still references <experimental/coroutine> which Visual Studio 18 (MSVC 14.51+) no longer supports. The new standard is C++20 <coroutine>.

Fix

Added -D_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to the existing add_definitions line in windows/CMakeLists.txt. This is the recommended interim fix per flutter/flutter#186452 until permission_handler_windows migrates to C++20 upstream.

Impact

  • Restores Windows desktop builds in CI and locally
  • No functional change to app behaviour
  • Can be removed once permission_handler_windows is updated upstream

Screenshots / Recordings

N/A — build fix, no UI changes

Checklist

  • No hard coding: I have used values from constants.dart or localization files instead of hard-coded values.
  • No end of file edits: No modifications done at end of resource files.
  • Code reformatting: I have formatted the code using dart format or the IDE formatter.
  • Code analysis: My code passes checks run in flutter analyze and tests run in flutter test.

UsbSerial.usbEventStream?.listen() and Connectivity()
.onConnectivityChanged.listen() were called without storing the
returned StreamSubscription objects, so they could never be
cancelled. This causes a memory leak on every hot-restart or
re-initialization as subscriptions accumulate.

Fix: store both subscriptions in _usbSubscription and
_connectivitySubscription fields, and cancel them in dispose().
The latest Visual Studio removed support for experimental C++ features
(/await compiler option, <experimental/coroutine>), causing the Windows
Flutter build to fail with error STL1011.

Adding _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to the
existing add_definitions call suppresses the error so Windows builds
work again while a permanent upstream fix is awaited in the
permission_handler_windows plugin.

Fixes fossasia#3246

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @prajakta128, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@prajakta128

Copy link
Copy Markdown
Contributor Author

Hi @marcnause, I noticed this issue was already resolved in #3279 — apologies for the duplicate PR, I will make sure to check for existing fixes before submitting next time. Feel free to close #3373.

@marcnause

Copy link
Copy Markdown
Contributor

Thank you for checking and thank you for your contribution anyway. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Flutter Build does not work anymore

2 participants