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

.NET MAUI SampleRate option crashes on Android. #2997

Closed
v-antunovic opened this issue Jan 1, 2024 · 4 comments · Fixed by #3258
Closed

.NET MAUI SampleRate option crashes on Android. #2997

v-antunovic opened this issue Jan 1, 2024 · 4 comments · Fixed by #3258
Labels
Bug Something isn't working MAUI

Comments

@v-antunovic
Copy link

v-antunovic commented Jan 1, 2024

Package

Sentry.Maui

.NET Flavor

.NET Core

.NET Version

8.0.0

OS

Android

SDK Version

3.41.3

Self-Hosted Sentry Version

No response

Steps to Reproduce

  1. Create .NET MAUI Blazor Hybrid applicaiton using Visual Studio template.
  2. Add Sentry.Maui nuget package
  3. Add .UseSentry() option (code below)
  4. Run app on Android emulator
var builder = MauiApp.CreateBuilder();
builder
    .UseMauiApp<App>()
    .ConfigureFonts(fonts =>
    {
        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
    }
    ).UseSentry(o =>
    {
        o.Dsn = "xxx";
        o.SampleRate = (float?)1.0;
    });
    // ...
    return builder.Build(); // Exception is thrown on this line

Expected Result

Sentry should work.

Actual Result

InvalidCastException is thrown on line

return builder.Build();

System.InvalidCastException: 'Specified cast is not valid.'

Base exception stack trace is

   at Sentry.SentrySdk.<>c__DisplayClass6_0.<InitSentryAndroidSdk>b__0(SentryAndroidOptions o)
   at Sentry.Android.Callbacks.OptionsConfigurationCallback.Configure(Object optionsObject)
   at Sentry.JavaSdk.Sentry.IOptionsConfigurationInvoker.n_Configure_Lio_sentry_SentryOptions_(IntPtr jnienv, IntPtr native__this, IntPtr native_p0)
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 125

SentryError

When runing on windows machine everything works fine, on android emulator it crashes.

@bitsandfoxes
Copy link
Contributor

Thanks for the detailed context and repro! I'll try to get this running locally as well.

@bitsandfoxes bitsandfoxes added Bug Something isn't working MAUI labels Jan 2, 2024
@bitsandfoxes
Copy link
Contributor

That one is a brainscratcher. I can irregularly reproduce this. But only in debug. The app starts just fine when simply launching on the device.

@IsmailHassani
Copy link

I have this issue also on the android emulator.
A couple weeks ago i came along an issue where http://localhost is not available on the emulator and http://10.0.2.2 should be used instead. I don't know where i saw this, but somewhere this sdk uses localhost for sampling.
This could explain why on debug this fails.

@bitsandfoxes
Copy link
Contributor

Thanks for sharing those insights!

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