-
-
Notifications
You must be signed in to change notification settings - Fork 355
Fix: Implement fallback system to screens that aren't reporting on the native layer the time to display. #4042
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
d0c0cf7
implement fallback system
lucas-zimerman 1a52620
clear format
lucas-zimerman 84301f7
backup
lucas-zimerman 3423a61
wip
lucas-zimerman 84c12ff
Merge branch 'main' into test/deadline
lucas-zimerman 1e59d5b
wip iOS
lucas-zimerman 8851215
ioscode
lucas-zimerman feb08cd
Merge branch 'main' into test/deadline
lucas-zimerman 299fb34
fix typo
lucas-zimerman 734354d
fix-time
lucas-zimerman dabf98b
removed wrapper placeholder, moved java implementation to separated f…
lucas-zimerman 41879c1
refactored android to use turbo module, refactored fallback emitter
lucas-zimerman a181bcc
add tests and minor fixes
lucas-zimerman 298a007
missing test file
lucas-zimerman a93b249
yarn fix
lucas-zimerman da76e21
fix ios module name
lucas-zimerman 53e67ba
Update samples/react-native/src/Screens/PerformanceScreen.tsx
lucas-zimerman 0344adb
Update samples/react-native/src/Screens/PerformanceScreen.tsx
lucas-zimerman b115fdd
Update samples/react-native/src/Screens/PerformanceScreen.tsx
lucas-zimerman 99e74cf
name missing
lucas-zimerman 1bb5c4d
Merge branch 'main' into test/deadline
lucas-zimerman 6507648
fix java module name, add isAvailable to ignore macos
lucas-zimerman 2f838b8
yarn fix
lucas-zimerman a8f5126
use impl method
lucas-zimerman fa03cc1
nit impl name
lucas-zimerman b6093d5
refactor how to use time to display fallback
lucas-zimerman d03004c
yarn fix
lucas-zimerman 7e5f764
fix ios reference
lucas-zimerman 49272a1
Merge branch 'main' into test/deadline
lucas-zimerman a22824b
changelog
lucas-zimerman c99200d
Apply suggestions from code review
lucas-zimerman 64fd760
Apply suggestions from code review
lucas-zimerman dc9ca95
fix build
lucas-zimerman 4710843
Removes unused java imports (#4119)
antonis 1cd3b8e
Merge branch 'main' into test/deadline
lucas-zimerman 54189db
Merge branch 'main' into test/deadline
lucas-zimerman 45fca09
add missing App Metrics import
lucas-zimerman 5c0681d
Merge branch 'main' into test/deadline
lucas-zimerman 966ce1e
refactor tests / remove closeAll
lucas-zimerman 4bb6434
commit java suggestion
lucas-zimerman add7f95
build fix
lucas-zimerman 55e6589
small refactor and add clearTimeout
lucas-zimerman 9885a15
use sentry timestampInSeconds
lucas-zimerman d87b40e
removed fallback from navigation, comment on timeout difference
lucas-zimerman 962bb35
requested changes java
lucas-zimerman 4b820fe
yarn fix / remove clearTimeout
lucas-zimerman a99c3c1
add note and fix time tests
lucas-zimerman 4203401
Kw fallback emitter suggestion (#4171)
lucas-zimerman 3dbcc41
Merge branch 'main' into test/deadline
lucas-zimerman 4557f7a
fix build
lucas-zimerman 9a5ce6d
fix test
lucas-zimerman 342961d
forgot git add for mocked file
lucas-zimerman 427e1c6
add try/catch block on java code
lucas-zimerman fcb9935
fix lint
lucas-zimerman 2a7c8fa
always use main thread on ttid
lucas-zimerman d43ce2b
Merge branch 'v5' into test/deadline
lucas-zimerman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
42 changes: 42 additions & 0 deletions
42
android/src/main/java/io/sentry/react/RNSentryTimeToDisplayModule.java
This file contains hidden or 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,42 @@ | ||
| package io.sentry.react; | ||
|
|
||
| import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.bridge.ReactMethod; | ||
| import com.facebook.react.bridge.Promise; | ||
| import com.facebook.react.turbomodule.core.interfaces.TurboModule; | ||
|
|
||
| import android.view.Choreographer; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
| import io.sentry.SentryDate; | ||
| import io.sentry.SentryDateProvider; | ||
| import io.sentry.android.core.SentryAndroidDateProvider; | ||
|
|
||
|
|
||
| public class RNSentryTimeToDisplayModule extends NativeRNSentryTimeToDisplaySpec { | ||
|
|
||
|
|
||
| public RNSentryTimeToDisplayModule(ReactApplicationContext reactContext) { | ||
| super(reactContext); | ||
| } | ||
|
|
||
| @ReactMethod | ||
| public void requestAnimationFrame(Promise promise) { | ||
| Choreographer choreographer = Choreographer.getInstance(); | ||
|
|
||
| // Invoke the callback after the frame is rendered | ||
| choreographer.postFrameCallback(new Choreographer.FrameCallback() { | ||
| @Override | ||
| public void doFrame(long frameTimeNanos) { | ||
| final @NotNull SentryDateProvider dateProvider = new SentryAndroidDateProvider(); | ||
|
|
||
| final SentryDate endDate = dateProvider.now(); | ||
|
|
||
| promise.resolve(endDate.nanoTimestamp() / 1e9); | ||
| } | ||
| }); | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
android/src/main/java/io/sentry/react/RNSentryTimeToDisplayPackage.java
This file contains hidden or 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,45 @@ | ||
| package io.sentry.react; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
|
|
||
| import com.facebook.react.TurboReactPackage; | ||
| import com.facebook.react.bridge.NativeModule; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.module.model.ReactModuleInfo; | ||
| import com.facebook.react.module.model.ReactModuleInfoProvider; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class RNSentryTimeToDisplayPackage extends TurboReactPackage { | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public NativeModule getModule(String name, ReactApplicationContext reactContext) { | ||
| if (name.equals(RNSentryTimeToDisplayModule.NAME)) { | ||
| return new RNSentryTimeToDisplayModule(reactContext); | ||
| } else { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public ReactModuleInfoProvider getReactModuleInfoProvider() { | ||
| return () -> { | ||
| final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>(); | ||
| boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; | ||
| moduleInfos.put( | ||
| RNSentryTimeToDisplayModule.NAME, | ||
| new ReactModuleInfo( | ||
| RNSentryTimeToDisplayModule.NAME, | ||
| RNSentryTimeToDisplayModule.NAME, | ||
| false, // canOverrideExistingModule | ||
| false, // needsEagerInit | ||
| true, // hasConstants | ||
| false, // isCxxModule | ||
| isTurboModule // isTurboModule | ||
| )); | ||
| return moduleInfos; | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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,7 @@ | ||
| #import <React/RCTBridgeModule.h> | ||
|
|
||
| @interface RNSentryTimeToDisplay : NSObject <RCTBridgeModule> | ||
|
|
||
| - (void)requestAnimationFrame:(RCTPromiseResolveBlock)resolve | ||
| rejecter:(RCTPromiseRejectBlock)reject; | ||
| @end |
This file contains hidden or 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,38 @@ | ||
| #import "RNSentryTimeToDisplay.h" | ||
| #import <QuartzCore/QuartzCore.h> | ||
| #import <React/RCTLog.h> | ||
|
|
||
| @implementation RNSentryTimeToDisplay | ||
antonis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| CADisplayLink *displayLink; | ||
| RCTPromiseResolveBlock resolveBlock; | ||
| } | ||
|
|
||
| RCT_EXPORT_MODULE(); | ||
|
|
||
| RCT_EXPORT_METHOD(requestAnimationFrame:(RCTPromiseResolveBlock)resolve | ||
| rejecter:(RCTPromiseRejectBlock)reject) | ||
| { | ||
| // Store the resolve block to use in the callback | ||
| resolveBlock = resolve; | ||
|
|
||
| // Create and add a display link to get the callback after the screen is rendered | ||
| displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)]; | ||
| [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; | ||
| } | ||
|
|
||
| - (void)handleDisplayLink:(CADisplayLink *)link | ||
| { | ||
| NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970]; | ||
|
|
||
| if (resolveBlock) { | ||
| resolveBlock(@(currentTime)); | ||
| resolveBlock = nil; | ||
| } | ||
|
|
||
| // Invalidate the display link | ||
| [displayLink invalidate]; | ||
| displayLink = nil; | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.