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

MAUI: Don't rely on DeviceDisplay/DeviceInformation #3474

Closed
daltzctr opened this issue Jul 10, 2024 · 1 comment · Fixed by #3521
Closed

MAUI: Don't rely on DeviceDisplay/DeviceInformation #3474

daltzctr opened this issue Jul 10, 2024 · 1 comment · Fixed by #3521
Labels
Bug Something isn't working MAUI

Comments

@daltzctr
Copy link

Package

Sentry.Maui

.NET Flavor

.NET

.NET Version

8.0.60

OS

Any (not platform specific)

SDK Version

4.7.0

Self-Hosted Sentry Version

No response

Steps to Reproduce

  1. Create a new MAUI project
  2. SentrySdk.CaptureMessage() from a separate thread
  3. Observe crashes

Expected Result

Does not crash

Actual Result

Crashes.

This is because DeviceDisplay & DeviceInformation are

  1. Not meant to be polled, which means the device reporting logic is dangerous
  2. Not thread safe on certain platforms (iOS, MacCatalyst, Windows).

Additionally, DeviceDisplay and DeviceInformation are not guarenteed to be valid in certain situations, such as startup, shutdown, or even in some cases in multi-window applications.

@jamescrosswell
Copy link
Collaborator

I'm not able to reproduce this on iOS 17.2 or macCatalyst, using the following sample code:

public partial class MainPage : ContentPage
{
    private int _count = 0;

    public MainPage()
    {
        InitializeComponent();
    }

    private void OnCounterClicked(object sender, EventArgs e)
    {
        _count++;
        var thread = new Thread(() =>
        {
            SentrySdk.CaptureMessage($"Click count: {_count}");
        });
        thread.Start();
        CounterBtn.Text = $"Click count: {_count}";
        thread.Join();
    }
}

@daltzctr are you able to provide a simple project and instructions on how to reproduce this reliably?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working MAUI
Projects
Status: Done
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants