-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow using multiple performance profilers (#76)
* feat: use instance level onRenderComplete callbacks instead of one global listener * update Android native to send instance-events instead of global * update onRenderComplete callback's usage * clean up * add an example with nested Profiler to fixture app * update after PR comments: - set LogLevel Debug for a global profiler - add a note about not using NestedContextScreen as an example
- Loading branch information
1 parent
19a7b51
commit a9b6a97
Showing
18 changed files
with
207 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import {ReactNavigationPerformanceView, useProfiledNavigation} from '@shopify/react-native-performance-navigation'; | ||
import {Button, Text, View, StyleSheet} from 'react-native'; | ||
import {StackNavigationProp} from '@react-navigation/stack'; | ||
import {PerformanceProfiler, LogLevel} from '@shopify/react-native-performance'; | ||
|
||
import {NavigationKeys, RootStackParamList} from '../constants'; | ||
|
||
/** | ||
* NOTE: This screen shouldn't be used as an example since we don't generally recommend mixing multiple profilers. | ||
* Nested profilers only make sense when transitioning between JS and native layers in a hybrid use case. | ||
* For example, in brown-field apps, gradually adopting React Native. | ||
* Please stick with only profiler per App if there is no serious matter to do otherwise. | ||
*/ | ||
|
||
const NestedContextScreen = () => { | ||
const {navigate} = useProfiledNavigation<StackNavigationProp<RootStackParamList, 'Examples'>>(); | ||
|
||
return ( | ||
<PerformanceProfiler logLevel={LogLevel.Debug}> | ||
<ReactNavigationPerformanceView screenName={NavigationKeys.NESTED_CONTEXT_SCREEN} interactive> | ||
<Button | ||
title="Present new screen inside nested Profiler Context" | ||
onPress={() => navigate(NavigationKeys.INNER_NESTED_CONTEXT_SCREEN)} | ||
/> | ||
</ReactNavigationPerformanceView> | ||
</PerformanceProfiler> | ||
); | ||
}; | ||
|
||
export const InnerNestedContextScreen = () => { | ||
const text = 'This is a screen rendered in a nested Profiler Context\n\n You should see no errors in the logs'; | ||
return ( | ||
<ReactNavigationPerformanceView screenName={NavigationKeys.INNER_NESTED_CONTEXT_SCREEN} interactive> | ||
<View style={styles.textContainer}> | ||
<Text style={styles.text}>{text}</Text> | ||
</View> | ||
</ReactNavigationPerformanceView> | ||
); | ||
}; | ||
|
||
export default NestedContextScreen; | ||
|
||
const styles = StyleSheet.create({ | ||
text: { | ||
textAlignVertical: 'center', | ||
textAlign: 'center', | ||
fontSize: 18, | ||
}, | ||
textContainer: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
...ndroid/src/main/kotlin/com/shopify/reactnativeperformance/RenderCompletionEventEmitter.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
packages/react-native-performance/ios/ReactNativePerformance/RenderCompletionEventEmitter.m
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
...es/react-native-performance/ios/ReactNativePerformance/RenderCompletionEventEmitter.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.