Skip to content
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

fixBug:android8.0以下获取帧率为0 #763

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void doReplayInner(String visibleScene, long startNs, long endNs, int dro

private class FrameCollectItem {
String visibleScene;
long sumFrameCost;
float sumFrameCost;
int sumFrame = 0;
int sumDroppedFrames;
// record the level of frames dropped each time
Expand Down Expand Up @@ -306,7 +306,7 @@ void collect(int droppedFrames) {
}

void report() {
float fps = Math.min(refreshRate, 1000.f * sumFrame / sumFrameCost);
float fps = 1000.f * sumFrame / sumFrameCost;
MatrixLog.i(TAG, "[report] FPS:%s %s", fps, toString());
try {
TracePlugin plugin = Matrix.with().getPluginByClass(TracePlugin.class);
Expand Down Expand Up @@ -398,12 +398,11 @@ public void onActivityStarted(Activity activity) {
@Override
public void onActivityResumed(Activity activity) {
lastResumeTimeMap.put(activity.getClass().getName(), System.currentTimeMillis());

this.refreshRate = (int) activity.getWindowManager().getDefaultDisplay().getRefreshRate();
if (useFrameMetrics) {
if (frameListenerMap.containsKey(activity.hashCode())) {
return;
}
this.refreshRate = (int) activity.getWindowManager().getDefaultDisplay().getRefreshRate();
this.frameIntervalNs = Constants.TIME_SECOND_TO_NANO / (long) refreshRate;
Window.OnFrameMetricsAvailableListener onFrameMetricsAvailableListener = new Window.OnFrameMetricsAvailableListener() {
@RequiresApi(api = Build.VERSION_CODES.O)
Expand Down