From b67f8756ced2905bfb6b722c644b3ec539677d53 Mon Sep 17 00:00:00 2001 From: Francesco Vigliaturo Date: Tue, 30 Jan 2024 17:21:55 +0100 Subject: [PATCH 1/3] Fix rendering issue --- internal/profile/android.go | 5 +++++ internal/profile/legacy.go | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/profile/android.go b/internal/profile/android.go index e437805..719ed5a 100644 --- a/internal/profile/android.go +++ b/internal/profile/android.go @@ -87,6 +87,11 @@ func (m AndroidMethod) ExtractPackageNameAndSimpleMethodNameFromAndroidMethod() } func (m AndroidMethod) FullMethodNameFromAndroidMethod() (string, error) { + // when we we're dealing with js frame that were "converted" + // to android methods (react-native) we don't have class name + if m.ClassName == "" { + return m.Name, nil + } var builder strings.Builder builder.WriteString(m.ClassName) // "" refers to the constructor in which case it's more readable to omit the method name. Note the method name diff --git a/internal/profile/legacy.go b/internal/profile/legacy.go index 6b76d84..2139ee3 100644 --- a/internal/profile/legacy.go +++ b/internal/profile/legacy.go @@ -148,7 +148,7 @@ func (p LegacyProfile) CallTrees() (map[uint64][]*nodetree.Node, error) { if p.Trace == nil { return nil, ErrProfileHasNoTrace } - _, ok := p.Trace.(Android) + _, ok := p.Trace.(*Android) // this is to handle only the Reactnative (android + js) // use case. If it's an Android profile but there is no // js profile, we'll skip this entirely @@ -176,7 +176,7 @@ func (p LegacyProfile) IsSampleFormat() bool { } func (p *LegacyProfile) Speedscope() (speedscope.Output, error) { - t, ok := p.Trace.(Android) + t, ok := p.Trace.(*Android) // this is to handle only the Reactnative (android + js) // use case. If it's an Android profile but there is no // js profile, we'll skip this entirely @@ -494,8 +494,13 @@ func getEventTimeFromElapsedNanoseconds(ns uint64) EventTime { } func unmarshalSampleProfile(p json.RawMessage) (sample.Trace, error) { + var objmap map[string]json.RawMessage + err := json.Unmarshal(p, &objmap) + if err != nil { + return sample.Trace{}, err + } var st sample.Trace - err := json.Unmarshal(p, &st) + err = json.Unmarshal(objmap["profile"], &st) if err != nil { return sample.Trace{}, err } From 768f6fef07f9767473b6d1ab84532c8a15817edf Mon Sep 17 00:00:00 2001 From: Francesco Vigliaturo Date: Tue, 30 Jan 2024 17:37:09 +0100 Subject: [PATCH 2/3] Define Struct to unrmarshal once instead of unmarshaling to a map and then to a sample.Trace --- internal/profile/legacy.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/internal/profile/legacy.go b/internal/profile/legacy.go index 2139ee3..ee130ae 100644 --- a/internal/profile/legacy.go +++ b/internal/profile/legacy.go @@ -493,19 +493,17 @@ func getEventTimeFromElapsedNanoseconds(ns uint64) EventTime { } } +type NestedProfile struct { + Profile sample.Trace `json:"profile"` +} + func unmarshalSampleProfile(p json.RawMessage) (sample.Trace, error) { - var objmap map[string]json.RawMessage - err := json.Unmarshal(p, &objmap) - if err != nil { - return sample.Trace{}, err - } - var st sample.Trace - err = json.Unmarshal(objmap["profile"], &st) + var np NestedProfile + err := json.Unmarshal(p, &np) if err != nil { return sample.Trace{}, err } - - return st, nil + return np.Profile, nil } // CallTree generation expect activeThreadID to be set in From 97a2a9db3c3abe53e170940404a1138d6517cc03 Mon Sep 17 00:00:00 2001 From: Francesco Vigliaturo Date: Tue, 30 Jan 2024 17:41:36 +0100 Subject: [PATCH 3/3] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf1efa..c3dae55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ **Bug Fixes**: - Label all node frames as system ([#392](https://github.com/getsentry/vroom/pull/392)) +- Fix react-native (android) rendering issue ([#397](https://github.com/getsentry/vroom/pull/397)) **Internal**: