Skip to content

Windows crashpad build support for older toolchains #2479

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

Open
filiph opened this issue Dec 10, 2024 · 19 comments
Open

Windows crashpad build support for older toolchains #2479

filiph opened this issue Dec 10, 2024 · 19 comments
Labels
9.0.0 Breaking-change dart Pull requests that update Dart code

Comments

@filiph
Copy link
Contributor

filiph commented Dec 10, 2024

Platform

Flutter Desktop Windows

Obfuscation

Disabled

Debug Info

Disabled

Doctor

[√] Flutter (Channel stable, 3.24.5, on Microsoft Windows [Version 10.0.22631.4602], locale en-US)
    • Flutter version 3.24.5 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (4 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

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

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

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.7.3)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
    • Visual Studio Build Tools 2022 version 17.7.34024.191
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.3)
    • 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 17.0.6+0-b2043.56-10027231)

[√] VS Code (version 1.95.3)
    • VS Code at C:\Users\filip\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.102.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.4602]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 122.0.6261.69
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 128.0.2739.42

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

• No issues found!

Version

8.11.0

Steps to Reproduce

  1. Run flutter build windows

(I assume there is probably some confounding factor but I'd rather file an incomplete bug than just abandon the filing altogether.)

Expected Result

App builds.

Actual Result

After upgrading from sentry 8.9.0 to version 8.11.0, my windows build fails with the following cryptic error:

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: The command "setlocal [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]        
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :cmEnd [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :cmErrorLevel [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: exit /b %1 [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :cmDone [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :VCEnd" exited with code 1. [D:\dev\giant_robot\build\windows\x64\INSTALL.vcxproj]  
Building Windows application...                                   168.6s
Build process failed.

After some digging, I realize the real error is hidden by the INSTALL.vcxproj machinery. Running the command in question ("C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake) on the command line produces the following output:

-- Install configuration: "Release"
CMake Error at _deps/sentry-native-build/crashpad_build/handler/cmake_install.cmake:41 (file):
  file cannot create directory:
  D:/dev/giant_robot/build/windows/x64/$<TARGET_FILE_DIR:giant_robot>/bin.
  Maybe need administrative privileges.
Call Stack (most recent call first):
  _deps/sentry-native-build/crashpad_build/cmake_install.cmake:46 (include)
  _deps/sentry-native-build/cmake_install.cmake:42 (include)
  plugins/sentry_flutter/cmake_install.cmake:37 (include)
  cmake_install.cmake:57 (include)

The error seems to be coming from _deps/sentry-native-build/crashpad_build/cmake_install.cmake. Line 41 of that file says:

file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE EXECUTABLE FILES "D:/dev/giant_robot/build/windows/x64/_deps/sentry-native-build/crashpad_build/handler/Release/crashpad_handler.exe")

Are you willing to submit a PR?

No

@filiph
Copy link
Contributor Author

filiph commented Dec 10, 2024

FWIW, downgrading to Sentry 8.10.0 fixes the issue.

@buenaflor
Copy link
Contributor

buenaflor commented Dec 10, 2024

thanks for the issue we'll have a look, this is the related PR

@buenaflor
Copy link
Contributor

cc @vaind

@vaind
Copy link
Collaborator

vaind commented Dec 11, 2024

After some digging, I realize the real error is hidden by the INSTALL.vcxproj machinery.

yeah... flutter/flutter#154977 -> flutter/flutter#143589

file cannot create directory:
D:/dev/giant_robot/build/windows/x64/$<TARGET_FILE_DIR:giant_robot>/bin.
Maybe need administrative privileges.

I haven't had this happen to me before but it looks like the file/directory was locked🤔 Have you tried a clean build, i.e. flutter clean and making sure the build folder doesn't exist? Have this happened elsewhere (CI)? Any chance the repo is public so I could try to reproduce directly?

@filiph
Copy link
Contributor Author

filiph commented Dec 11, 2024

Yes, this is after flutter clean. Sorry I didn't mention it in the OP.

The project isn't open source but if you agree, I'm happy to give you access to it (it's a private repo on GitHub).

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 11, 2024
@vaind
Copy link
Collaborator

vaind commented Dec 11, 2024

Yes, this is after flutter clean. Sorry I didn't mention it in the OP.

The project isn't open source but if you agree, I'm happy to give you access to it (it's a private repo on GitHub).

As long as it's the dev setup is reasonable, that would probably be the fastest way to get this fixed.

@filiph
Copy link
Contributor Author

filiph commented Dec 11, 2024

As long as it's the dev setup is reasonable, that would probably be the fastest way to get this fixed.

Great! I just sent you an invite. You just need Git LFS installed, otherwise all should be straightforward.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 11, 2024
@vaind
Copy link
Collaborator

vaind commented Dec 11, 2024

flutter build windows works on an incremental build as well as a clean build (tested both latest stable v8.11.0 and beta 8.12.0-beta.1)

Image

Interestingly, it doesn't even try to create the bin/ directory

Relevant flutter doctor output shows only a difference in MSVC though I doubt that would make a difference.

[✓] Flutter (Channel stable, 3.24.5, on Microsoft Windows [Version 10.0.26100.2314], locale en-US)
    • Flutter version 3.24.5 on channel stable at C:\Users\dlugo\scoop\apps\flutter\3.24.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (4 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

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

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.11.35327.3
    • Windows 10 SDK version 10.0.22000.0

[✓] VS Code (version 1.95.3)
    • VS Code at C:\Users\dlugo\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.102.0

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

Maybe you could try nuking any changes in your current directory (be sure to commit+push first :) ): git clean -ffxd if that helps?

@vaind
Copy link
Collaborator

vaind commented Dec 11, 2024

Also, maybe it has something to do with a cmake version, mine is cmake --version: 3.31.0

@Bilonik
Copy link

Bilonik commented Dec 11, 2024

For us its compiles for release but crash as soon as we open it.

Downgrading to 8.10.1 fix the issue.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 11, 2024
@vaind
Copy link
Collaborator

vaind commented Dec 11, 2024

For us its compiles for release but crash as soon as we open it.

Downgrading to 8.10.1 fix the issue.

That sounds like a separate issue. Could you file a GH issue with more details? e.g. if there are any logs, any issues reported in Sentry, if the same happens in debug builds, etc.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 17, 2024
@vaind
Copy link
Collaborator

vaind commented Dec 17, 2024

This is reproducible with VisualStudio 2019 (reproduced in GHActions on #2511). Before a fix is in place, you can try updating to the latest VisualStudio 2022

@filiph
Copy link
Contributor Author

filiph commented Dec 17, 2024

you can try updating to the latest VisualStudio 2022

This fixed the issue for me. For other people like me who aren't familiar with VisualStudio tools, you can run "Visual Studio Installer" (that should already be on your computer if you're building windows apps) and click the Update all button.

Image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 17, 2024
@wispborne
Copy link

wispborne commented Dec 18, 2024

This is the same state with which the build failed for me - I opened the INSTALL.vcxproj file in VS 2022 Preview (Version 17.13.0 Preview 2.0):

Image

@vaind
Copy link
Collaborator

vaind commented Dec 18, 2024

This is the same state with which the build failed for me - I opened the INSTALL.vcxproj file in VS 2022 Preview (Version 17.13.0 Preview 2.0):

Just opening vcxproj won't work, you need to rebuild with flutter clean && flutter build windows (and make sure it's actually using the latest MSVC (no experience with that, but at least checking the output of flutter doctor --verbose is a good baseline)

@vaind
Copy link
Collaborator

vaind commented Dec 20, 2024

Just released v8.11.2 disabled the native crash reporting by default, you can reenable it by setting an env var:

(the following code is for powershell, assuming that's what you use on Windows)

$env:SENTRY_NATIVE_BACKEND = 'crashpad'
flutter build windows

You could read about various backends in https://docs.sentry.io/platforms/native/advanced-usage/backend-tradeoffs/ but TLDR is that crashpad is preferrable unless you cannot use it, e.g. because you cannot ship an additional executable along your app. If that's the case, there's breakpad and inproc, which both run in the same process, have some advantages over each other. If you don't care about these (they're described in docs), breakpad would be the next best thing after crashpad.

I'm keeping the issue open - we'll need to decide how to proceed with older MSVC support before v9 when we reenable crashpad by default.

@vaind vaind added the 9.0.0 label Dec 20, 2024
@vaind vaind changed the title Build fail on Windows: file cannot create directory Windows crashpad build support for older toolchains Dec 24, 2024
@vaind vaind removed the bug label Dec 24, 2024
@buenaflor buenaflor moved this from In Progress to Backlog in [DEPRECATED] Mobile SDKs Jan 16, 2025
@buenaflor buenaflor added this to the 9.0.0 milestone Jan 16, 2025
@buenaflor buenaflor removed this from the 9.0.0 milestone Feb 11, 2025
@stephanie-anderson stephanie-anderson added the dart Pull requests that update Dart code label Apr 16, 2025 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9.0.0 Breaking-change dart Pull requests that update Dart code
Projects
Status: No status
Status: Backlog
Development

No branches or pull requests

6 participants