Closed Hamid313-coder closed 1 month ago
This issue has eaten the last four days of my life, so bare with me if this explanation takes a bit.
mutex
from the VC++ runtime, but which requires that you follow the "at least as new as the latest toolset" rule. They even note in the changelog thatPrograms that aren't following the documented restrictions on binary compatibility may encounter null dereferences in mutex machinery"
Github have updated their windows
and windows-latest
runner images to use the newest Visual Studio, which has caused a bit of chaos generally: https://github.com/actions/runner-images/issues/10004
The upshot of this is that if any of the Flutter plugins you are using use mutex
, and you are building the app on a machine that has VS2022 17.10 or newer, and your users don't already have VC++ runtime 14.40.33810.0 or newer, your app will crash as soon as the plugin tries to use the mutex
As far as fixes are concerned, I'm not sure the best approach here. The current approach of bundling an static version of the VC++ redist with this module is fundamentally broken, but I acknowledge that we need some kind of fix to make it easier to bundle the required libraries with the installer.
I'm still working through a proper fix for my app, and will report back once I have one.
OK - I have a workaround that Works For Me:
msix
that includes the MSVC librariesI'll work on getting a proper PR up and getting my package onto pub.dev - for now, you'll need to use the packages from git. Update your pubspec like:
dependencies:
msvcredist:
git:
url: https://github.com/insertjokehere/flutter_msvcredist.git
ref: main
dev_dependencies:
msix:
git:
url: https://github.com/insertjokehere/msix.git
ref: msvc_redist
Thank you for discovering the problem. I noticed that my local build worked fine but production build in GitHub Actions had the crash, and I analyzed the difference between the MSIX files and saw that they had a different DLL for a WebRTC plugin I use (which in an older version, immediately initiated an audio connection (still don't know why it gets a different DLL for it, but that's another issue)).
This made the app crash on startup, only in the production build lol. I also noticed that it had the old msvcp140.dll, vcruntime140.dll, and vcruntime140_1.dll. I noticed that replacing them with the new versions fixed it (or leaving them and instead changing the DLL of the WebRTC plugin). I was going to fix it by changing the DLL's manually, but I like the closure of knowing that it was audio (mutex) specifically that was causing the issue
OK - I have a workaround that Works For Me:
- https://github.com/insertjokehere/msix/tree/msvc_redist removes the logic from
msix
that includes the MSVC libraries- https://github.com/insertjokehere/flutter_msvcredist copies the libraries that your app is linked against from the build environment so you get the correct versions.
I'll work on getting a proper PR up and getting my package onto pub.dev - for now, you'll need to use the packages from git. Update your pubspec like:
dependencies: msvcredist: git: url: https://github.com/insertjokehere/flutter_msvcredist.git ref: main dev_dependencies: msix: git: url: https://github.com/insertjokehere/msix.git ref: msvc_redist
Thank you for posting this workaround! We had a similar issue on Windows 11 where our Flutter Windows app crashing whenever we accessed the webcam through the camera_windows library. We're also using this msix package for bundling our Windows app with flutter as well. This workaround helped us resolve that crash! I hope they release a permanent fix soon.
Error find from Event Viewer Faulting module name: MSVCP140.dll, version: 14.26.28804.1, time stamp: 0x5e9b29e5 Exception code: 0xc0000005
@riccardo-lomazzi fix it https://github.com/YehudaKremer/msix/pull/273 (version 3.16.8) sorry for the late response.
When I build my flutter windows app which has "audio_players" and "video_player" on windows 11 using msix, it crashes and closes the app when I play sound or play video. I checked using "Event Viewer". it says the fault is from msvcp140.dll file. when I replace that .dll file with file which is located in "visual studio" folder. it works fine.