-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
652a8dc
commit 61b5835
Showing
3 changed files
with
39 additions
and
51 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
packages/core/android/src/main/java/io/sentry/RNSentryTimeToDisplay.java
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
39 changes: 39 additions & 0 deletions
39
packages/core/android/src/main/java/io/sentry/react/RNSentryTimeToDisplay.java
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,39 @@ | ||
package io.sentry.react; | ||
|
||
import android.os.Handler; | ||
import android.os.Looper; | ||
import android.view.Choreographer; | ||
import com.facebook.react.bridge.Promise; | ||
import io.sentry.SentryDate; | ||
import io.sentry.SentryDateProvider; | ||
|
||
public class RNSentryTimeToDisplay { | ||
public static void GetTimeToDisplay(Promise promise, SentryDateProvider dateProvider) { | ||
Looper mainLooper = Looper.getMainLooper(); | ||
|
||
if (mainLooper == null) { | ||
promise.reject( | ||
"GetTimeToDisplay is not able to measure the time to display: Main looper not" | ||
+ " available."); | ||
return; | ||
} | ||
|
||
// Ensure the code runs on the main thread | ||
new Handler(mainLooper) | ||
.post( | ||
() -> { | ||
try { | ||
Choreographer choreographer = Choreographer.getInstance(); | ||
|
||
// Invoke the callback after the frame is rendered | ||
choreographer.postFrameCallback( | ||
frameTimeNanos -> { | ||
final SentryDate endDate = dateProvider.now(); | ||
promise.resolve(endDate.nanoTimestamp() / 1e9); | ||
}); | ||
} catch (Exception exception) { | ||
promise.reject("Failed to receive the instance of Choreographer", exception); | ||
} | ||
}); | ||
} | ||
} |