-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat: allow using multiple performance profilers #76
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes re: rendering callbacks make sense to me - have not 🎩 but i'd love to do this locally - what are the steps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎩 'd and works well 👍
fixture/src/App.tsx
Outdated
@@ -53,7 +70,7 @@ const App = () => { | |||
return ( | |||
<> | |||
<ApolloProvider client={apolloClient}> | |||
<PerformanceProfiler logLevel={LogLevel.Debug}> | |||
<PerformanceProfiler logLevel={LogLevel.Error}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should at least keep LogLevel.Warn
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely, I used it for testing and forgot to remove 👍
- set LogLevel Debug for a global profiler - add a note about not using NestedContextScreen as an example
I was able to test this on Shopify Mobile for Android & iOS - this change fixed the reported issue :) |
Motivation
The motivation behind this change is to allow using the library in brownfield apps with multiple entry points
Native
<->React Native
.Description
Currently if multiple
PerformanceProfiler
instances are used in an app, they will “mix” render completion events. BecauseuseNativeRenderCompletionEvents
listens onlyRENDER_COMPLETION_EVENT_NAME
and does not differentiate between 2 contexts running at the same time. That results inScreenProfilerNotStartedError
when a screen is pushed in the other context.This PR changes the way native
onRenderCompleted
event gets reported.Before
PerformanceProfiler
would listen to allRENDER_COMPLETION_EVENT_NAME
events reported by native views and pass them toStateController
. Now listening toonRenderCompleted
event is moved down toPerformanceMeasureView.tsx
level and became an instance-level event, instead of global one. Now when events don't go up toPerformanceProfiler
, they don't get mixed up when we have multiple Profilers running.Packages affected:
react-native-performance
Test plan
It's not easy to reproduce the issue in
fixture
app. I suggest to first runfixture
and confirm that nothing is broken, and after that test the fix in Shopify Mobile.Testing in the fixture app:
rm -rf fixture/dist && yarn up && yarn ios/android
to run a clean build with the fixNested Context Screen
- you are already inside the nestedProfilerContext
and should see no errors in logsProfilerContext
- again, you should see no errors in logstesting-nested-profiler.mov
Tips:
Nested Context Screen
, or after.LogLevel
for the mainProfilerContext
toLogLevel.Error
, but set a lower level (Debug
) for the nested profiler inNestedContextScreen
:<PerformanceProfiler logLevel={LogLevel.Debug}>
. You should see no performance logs before entering nested context, and start getting them once openingNested Context Screen
Checklist