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**: 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..ee130ae 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 @@ -493,14 +493,17 @@ func getEventTimeFromElapsedNanoseconds(ns uint64) EventTime { } } +type NestedProfile struct { + Profile sample.Trace `json:"profile"` +} + func unmarshalSampleProfile(p json.RawMessage) (sample.Trace, error) { - var st sample.Trace - err := json.Unmarshal(p, &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