Use DecimalFormat instead of String.format.
Speculative fix to a problem where String.format crashes with "java.lang.NullPointerException at Formatter$FormatSpecifier.addZeros : Attempt to get length of null array" on some devices. Bug: b/80240768 Change-Id: I8e67b7107a37ad7d6f978b9de368f14d37efecb2 Reviewed-on: https://webrtc-review.googlesource.com/80883 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23523}
This commit is contained in:
committed by
Commit Bot
parent
5daaf7dbc6
commit
1659e97767
@ -19,9 +19,9 @@ import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.view.Surface;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
@ -665,6 +665,7 @@ public class EglRenderer implements VideoRenderer.Callbacks, VideoSink {
|
||||
}
|
||||
|
||||
private void logStatistics() {
|
||||
final DecimalFormat fpsFormat = new DecimalFormat("#.0");
|
||||
final long currentTimeNs = System.nanoTime();
|
||||
synchronized (statisticsLock) {
|
||||
final long elapsedTimeNs = currentTimeNs - statisticsStartTimeNs;
|
||||
@ -676,7 +677,7 @@ public class EglRenderer implements VideoRenderer.Callbacks, VideoSink {
|
||||
+ " Frames received: " + framesReceived + "."
|
||||
+ " Dropped: " + framesDropped + "."
|
||||
+ " Rendered: " + framesRendered + "."
|
||||
+ " Render fps: " + String.format(Locale.US, "%.1f", renderFps) + "."
|
||||
+ " Render fps: " + fpsFormat.format(renderFps) + "."
|
||||
+ " Average render time: " + averageTimeAsString(renderTimeNs, framesRendered) + "."
|
||||
+ " Average swapBuffer time: "
|
||||
+ averageTimeAsString(renderSwapBufferTimeNs, framesRendered) + ".");
|
||||
|
||||
Reference in New Issue
Block a user