Skip to content

Conversation

@miquelbeltran
Copy link
Member

Description

As discussed in #2957 seems that some Windows VMs will return 0 when asked for physical device memory, which causes the plugin to throw an exception.

The main issue is that 3rd party devs using this plugin in their packages may not properly catch exceptions.

This PR replaces these types of exception errors with returning default values, to avoid uncaught exceptions.

Related Issues

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

Copy link
Collaborator

@vbuberen vbuberen left a comment

Choose a reason for hiding this comment

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

Feels like it would be good to release this fix today

@miquelbeltran miquelbeltran merged commit 084730f into main Jan 28, 2025
20 checks passed
@miquelbeltran miquelbeltran deleted the fix/2957 branch January 28, 2025 09:51
@vbuberen vbuberen changed the title fix: #2957 replaces throwing exception with returning default values fix(device_info_plus): #2957 replaces throwing exception with returning default values Jan 28, 2025
@birnam
Copy link

birnam commented Apr 18, 2025

I just wanted to add this info to the ticket: this not only happens with Windows VMs, but it can happen if you are running Windows with Microsoft Hyper-V active. This (IMO) significantly expands the likelyhood of clients running into this error, as Hyper-V might have been activated for WSL users, Docker Desktop users, and users that want to run some hypervizors while passing virtualization features to VMs.

Returning a 0 instead of throwing an error was an ok solution. In future perhaps adding a fallback using GlobalMemoryStatusEx, which doesn't get blocked in VMs, would work better.

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.

[Bug]: DeviceInfoPlugin class on Windows 10 crashes when windowsInfo is called.

4 participants