DecodeProducer: simplify tracing
@@ -28,9 +28,7 @@ import com.facebook.imagepipeline.image.EncodedImage
import com.facebook.imagepipeline.image.ImmutableQualityInfo
import com.facebook.imagepipeline.image.QualityInfo
import com.facebook.imagepipeline.producers.JobScheduler.JobRunnable
-import com.facebook.imagepipeline.systrace.FrescoSystrace.beginSection
-import com.facebook.imagepipeline.systrace.FrescoSystrace.endSection
-import com.facebook.imagepipeline.systrace.FrescoSystrace.isTracing
+import com.facebook.imagepipeline.systrace.FrescoSystrace.traceSection
import com.facebook.imagepipeline.transcoder.DownsampleUtil
import com.facebook.imageutils.BitmapUtil
import java.lang.Exception
@@ -61,11 +59,8 @@ class DecodeProducer(
override fun produceResults(
consumer: Consumer<CloseableReference<CloseableImage?>>,
context: ProducerContext
- ) {
- try {
- if (isTracing()) {
- beginSection("DecodeProducer#produceResults")
- }
+ ) =
+ traceSection("DecodeProducer#produceResults") {
val imageRequest = context.imageRequest
val progressiveDecoder =
if (!UriUtil.isNetworkUri(imageRequest.sourceUri)) {
@@ -82,11 +77,6 @@ class DecodeProducer(
this.maxBitmapSize)
}
this.inputProducer.produceResults(progressiveDecoder, context)
- } finally {
- if (isTracing()) {
- endSection()
- }
- }
}
private abstract inner class ProgressiveDecoder(
@@ -114,11 +104,8 @@ class DecodeProducer(
encodedImage.sampleSize = sampleSize
}
- public override fun onNewResultImpl(newResult: EncodedImage?, @Consumer.Status status: Int) {
- try {
- if (isTracing()) {
- beginSection("DecodeProducer#onNewResultImpl")
- }
+ public override fun onNewResultImpl(newResult: EncodedImage?, @Consumer.Status status: Int) =
+ traceSection("DecodeProducer#onNewResultImpl") {
val isLast = isLast(status)
if (isLast) {
if (newResult == null) {
@@ -136,11 +123,6 @@ class DecodeProducer(
if (isLast || isPlaceholder || producerContext.isIntermediateResultExpected) {
jobScheduler.scheduleJob()
}
- } finally {
- if (isTracing()) {
- endSection()
- }
- }
}
override fun onProgressUpdateImpl(progress: Float) {
