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

Missing source context with MAUI apps #2177

Closed
Tracked by #42
mattjohnsonpint opened this issue Feb 11, 2023 · 16 comments
Closed
Tracked by #42

Missing source context with MAUI apps #2177

mattjohnsonpint opened this issue Feb 11, 2023 · 16 comments
Assignees
Labels

Comments

@mattjohnsonpint
Copy link
Contributor

mattjohnsonpint commented Feb 11, 2023

Having trouble getting source context working for MAUI Android apps, but can get them for non-MAUI Android apps.

The same result occurs whether uploading the sources to Sentry, or embedding them in the PDBs. However, it's easier to see by embedding because we can validate sources are missing before sending any events.

Consider:

dotnet new android -n AndroidApp1
cd AndroidApp1
dotnet build -c Release -p:EmbedAllSources=true
sentry-cli dif check bin/Release/net7.0-android/AndroidApp1.pdb

Output:

Debug Info File Check
  Type: portablepdb debug companion
  Contained debug identifiers:
    > Debug ID: fe0b41d6-17e0-4a56-b496-9837a32f58f8-afd2ae0f
      Arch:     unknown
  Contained debug information:
    > debug, sources
  Usable: yes

Looks good, and sources work. Now the same with MAUI:

dotnet new maui -n MauiApp1
cd MauiApp1
dotnet build -c Release -f net7.0-android -p:EmbedAllSources=true
sentry-cli dif check bin/Release/net7.0-android/MauiApp1.pdb

Output:

Debug Info File Check
  Type: portablepdb debug companion
  Contained debug identifiers:
    > Debug ID: 879cb913-665a-4785-8aea-8cb0d99d1e14-ad967672
      Arch:     unknown
  Contained debug information:
    > debug
  Usable: yes

Sentry-cli shows debug only. sources is missing.

Sources do appear if compiling in Debug configuration.

Needs more investigation to figure out if sources aren't being found (which we could document or workaround), or if the format is different somehow (which would require a change to Symbolic), or if something else is at play.

@mattjohnsonpint
Copy link
Contributor Author

mattjohnsonpint commented Feb 11, 2023

Just to clarify, I can do the same thing without embedding sources. First add the Sentry .NET SDK (or MAUI SDK), then build in release mode, and then use sentry-cli dif upload --include-sources (or integrated <SentryUploadSources>true</SentryUploadSources>), then do something that sends an event to Sentry.

In either case, whether uploading sources separately or embedded, source context does appear for plain .NET Android apps, but not for MAUI .NET Android apps.

No difference in behavior between .NET 6 and 7.

@mattjohnsonpint
Copy link
Contributor Author

mattjohnsonpint commented Feb 11, 2023

@Swatinem @vaind - have a look? Here are the two project's symbol files. Both should have embedded sources. Can you see if they actually do please?

Symbols.zip

Thanks.

@mattjohnsonpint mattjohnsonpint changed the title Missing source context with MAUI Android apps Missing source context with MAUI apps Feb 13, 2023
@mattjohnsonpint
Copy link
Contributor Author

mattjohnsonpint commented Feb 13, 2023

Testing a bit more, and something similar (but not quite identical) is happening for iOS.

A MAUI iOS app gets source context only when EmbedAllSources is true. Using sentry-cli, or SentryUploadSources does not appear to work.

However, a non-MAUI iOS app (dotnet new ios) does get source context when SentryUploadSources was used.

Something about MAUI specifically is interfering with source context. Not sure what.

@mattjohnsonpint
Copy link
Contributor Author

Also note that sometimes the debug info will show erroneously in Sentry as "Deleted"

image

But I don't believe this is related, because when sources are uploaded separately the source bundle is labeled "Ok"

image

Also the debug file isn't really deleted, but somehow the status is incorrectly reported. More on this in getsentry/sentry#44485

@vaind
Copy link
Collaborator

vaind commented Feb 15, 2023

Symbols.zip

With the new util to print sources in a PDB, we can see the MAUI one doesn't embed the sources.

PS ...> c:\dev\sentry-cli\\target\release\sentry-cli.exe dif dump-sources .\MauiApp1.pdb
portablepdb 879cb913-665a-4785-8aea-8cb0d99d1e14-ad967672 has no sources.
PS ...> c:\dev\sentry-cli\\target\release\sentry-cli.exe dif dump-sources .\AndroidApp1.pdb
portablepdb fe0b41d6-17e0-4a56-b496-9837a32f58f8-afd2ae0f references sources:
  /Users/matt/temp/AndroidApp1/MainActivity.cs
    Embedded, 356 bytes
  /Users/matt/temp/AndroidApp1/obj/Release/net7.0-android/AndroidApp1.GlobalUsings.g.cs
    Embedded, 407 bytes
  /Users/matt/temp/AndroidApp1/obj/Release/net7.0-android/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs
    Embedded, 197 bytes
  /Users/matt/temp/AndroidApp1/obj/Release/net7.0-android/AndroidApp1.AssemblyInfo.cs
    Embedded, 1103 bytes
  /Users/matt/temp/AndroidApp1/obj/Release/net7.0-android/Resource.designer.cs
    Embedded, 2376 bytes

@vaind
Copy link
Collaborator

vaind commented Feb 15, 2023

On the other hand, dotpeek shows them... needs more investigation.

  <Document Index="1" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-1" Checksum="03 53 3a d3 06 fd f5 c9 f2 aa 14 01 ae ef 3c ec d4 e3 c1 71 ">/Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/Resources_Styles_Colors.xaml.sg.cs</Document>
  <Document Index="2" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-1" Checksum="48 b3 b7 20 e0 6a 48 68 8c 8f 45 bc bc 15 8f 7e 8b bb f9 ca ">/Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/Resources_Styles_Styles.xaml.sg.cs</Document>
  <Document Index="3" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-256" Checksum="6d 2e 43 47 3a d2 58 1f 4d 2e 66 3c 43 21 a3 2b 39 61 5d b5 9f 60 69 0d 94 75 89 01 e3 70 40 c7 ">/Users/matt/temp/MauiApp1/App.xaml.cs</Document>
  <Document Index="4" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-1" Checksum="cc 9f bc 96 68 48 63 2e 3f e6 f6 97 a5 b8 ce 08 99 54 5c b6 ">/Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/App.xaml.sg.cs</Document>
  <Document Index="5" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-256" Checksum="b6 53 d8 54 b1 e7 55 3c d9 cd 82 ef bc 66 7b 2d 53 be 45 68 22 8f 9e 01 42 e6 9e de 66 c8 a7 78 ">/Users/matt/temp/MauiApp1/AppShell.xaml.cs</Document>
  <Document Index="6" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-1" Checksum="fe 86 e9 03 55 22 cc 7c 54 53 d5 f5 54 4e e3 d8 dd 5f 7b fc ">/Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/AppShell.xaml.sg.cs</Document>
  <Document Index="7" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-256" Checksum="d1 4d fa 83 89 c1 30 be 69 4f 4e 66 91 f7 5c a7 0b 37 05 ea 4f b8 2b af 82 3f 7b c2 7f a2 81 3d ">/Users/matt/temp/MauiApp1/MainPage.xaml.cs</Document>
  <Document Index="8" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-1" Checksum="ad 38 ca 50 aa 90 99 cc 5b 49 81 bd cf c8 3f 7b ae ec 0d 27 ">/Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/MainPage.xaml.sg.cs</Document>
  <Document Index="9" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-256" Checksum="82 41 d3 88 41 cf 0c 46 bd ab ee 98 cb e3 c1 7f 8a 9e f2 4d b4 6e dc e8 01 05 ab 8b 7f cd 91 7e ">/Users/matt/temp/MauiApp1/MauiProgram.cs</Document>
  <Document Index="10" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-256" Checksum="2b 66 c1 38 40 a6 ed a1 8b 8f b3 f4 5f 32 e1 af ac 0b 02 9d c7 c5 8e 5a 7e f7 69 c4 50 22 85 2c ">/Users/matt/temp/MauiApp1/Platforms/Android/MainApplication.cs</Document>
  <Document Index="11" DocumentType="Text" Language="C#" LanguageVendor="Microsoft" ChecksumAlgorithm="SHA-256" Checksum="5b 40 47 53 bb 85 94 6b 73 4c 26 70 bd b4 7e 82 d2 fd 70 dd ea dc df f9 24 82 43 68 bd 47 cc df ">/Users/matt/temp/MauiApp1/obj/Release/net7.0-android/Resource.designer.cs</Document>

@vaind
Copy link
Collaborator

vaind commented Feb 15, 2023

OK, so after also printing non-embedded sources, the dump matches dotpeek output:

c:\dev\sentry-cli\\target\release\sentry-cli.exe dif dump-sources .\MauiApp1.pdb
portablepdb 879cb913-665a-4785-8aea-8cb0d99d1e14-ad967672 references sources:
  /Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/Resources_Styles_Colors.xaml.sg.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/Resources_Styles_Styles.xaml.sg.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/App.xaml.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/App.xaml.sg.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/AppShell.xaml.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/AppShell.xaml.sg.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/MainPage.xaml.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/MainPage.xaml.sg.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/MauiProgram.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/Platforms/Android/MainApplication.cs
    Not embedded nor available locally at the referenced path.
  /Users/matt/temp/MauiApp1/obj/Release/net7.0-android/Resource.designer.cs
    Not embedded nor available locally at the referenced path.

@mattjohnsonpint
Copy link
Contributor Author

Does that at all explain why uploading sources with SentryUploadSources (i.e. sentry-cli dif upload --include-sources) would not work for a MAUI Android app?

@vaind
Copy link
Collaborator

vaind commented Feb 15, 2023

Does that at all explain why uploading sources with SentryUploadSources (i.e. sentry-cli dif upload --include-sources) would not work for a MAUI Android app?

Not really. Maybe that's the same issue as the iOS one?

@mattjohnsonpint
Copy link
Contributor Author

I don't have symbolication problems on Android, just source context. But perhaps related to trimming. I'm not sure.

@vaind
Copy link
Collaborator

vaind commented Feb 15, 2023

I've just tried reproducing locally with the given steps to create a new maui app, build for android release, upload with "--include-sources" and everything works fine:

https://sentry-sdks.sentry.io/issues/3893145000/events/940cd008a2f6425b8c0689ec83c5bd40/?project=5428537

I did use a latest local build of sentry-cli though, not sure it makes a difference...

@vaind
Copy link
Collaborator

vaind commented Feb 15, 2023

I did use a latest local build of sentry-cli though, not sure it makes a difference...

OK, it does because the latest released version from getsentry/sentry-cli fails with error: malformed debug info file & caused by: invalid custom debug information table item tag 0 - so it doesn't have the recent fix added to skip these.

What version have you tried uploading with @mattjohnsonpint?

@vaind
Copy link
Collaborator

vaind commented Feb 15, 2023

As for the embedded sources in MAUI PDB - this is a bug in symbolic, see getsentry/symbolic#759

@mattjohnsonpint mattjohnsonpint self-assigned this Feb 27, 2023
@bruno-garcia
Copy link
Member

bruno-garcia commented Feb 27, 2023

@mattjohnsonpint
Copy link
Contributor Author

mattjohnsonpint commented Feb 28, 2023

When I first opened this issue, I was using Sentry CLI 2.12.0. It still reproduces with 2.13.0. However, if I build Sentry Cli from main, it appears to be fixed. Looks like Sentry CLI recently had Symbolic bumped to 12, but hasn't been released yet. So I expect this should be resolved with the next release of Sentry CLI (2.13.1 or 2.14.0).

I'll leave this open to validate after we can update. Thanks!

@mattjohnsonpint
Copy link
Contributor Author

mattjohnsonpint commented Mar 19, 2023

This is fixed as of Sentry .NET 3.29.0.

Example with source context from MAUI app built in Release mode:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

3 participants