Skip to content

Commit 30c7314

Browse files
committed
Revert "Pre-emptively take a snapshot when finishing an activity before changing visibility"
This reverts commit 6dad90e. When opening and closing activities in Settings, a significant amount of CPU time is spent rendering and compressing JPEG screenshots, as reported by simpleperf: 0.46% /system/lib64/libjpeg.so encode_mcu_gather 0.37% /system/lib64/libhwui.so neon::S32_alpha_D32_filter_DX(SkBitmapProcState const&, unsigned int const*, int, unsigned int*) 0.29% /system/lib64/libjpeg.so jsimd_extrgbx_ycc_convert_neon 0.27% /system/lib64/libjpeg.so jsimd_fdct_islow_neon 0.23% /system/lib64/libjpeg.so jsimd_huff_encode_one_block_neon 0.14% /system/lib64/libjpeg.so jsimd_quantize_neon Call graph tracing reveals that TaskSnapshotPersister is responsible for taking the screenshots: 0.16% 0.16% /system/lib64/libjpeg.so encode_mcu_gather | -- encode_mcu_gather | --50.00%-- compress_output process_data_simple_main jpeg_write_scanlines SkJpegEncoder::onEncodeRows(int) SkJpegEncoder::Encode(SkWStream*, SkPixmap const&, SkJpegEncoder::Options const&) SkEncodeImage(SkWStream*, SkPixmap const&, SkEncodedImageFormat, int) android::Bitmap::compress(SkBitmap const&, android::Bitmap::JavaCompressFormat, int, SkWStream*) android::Bitmap::compress(android::Bitmap::JavaCompressFormat, int, SkWStream*) Bitmap_compress(_JNIEnv*, _jobject*, long, int, int, _jobject*, _jbyteArray*) art_jni_trampoline android.graphics.Bitmap.compress com.android.server.wm.TaskSnapshotPersister$StoreWriteQueueItem.writeBuffer com.android.server.wm.TaskSnapshotPersister$StoreWriteQueueItem.write com.android.server.wm.TaskSnapshotPersister$1.run art_quick_invoke_stub art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*) art::Thread::CreateCallback(void*) __pthread_start(void*) __start_thread Manual code tracing leads to ActivityRecord as the culprit, as it takes a screenshot every time an Activity is finished. This doesn't appear to be critical, so revert the commit that added it in order to reduce excess CPU usage. Test: simpleperf record -a; verify that libjpeg-turbo no longer appears in top sample hits Change-Id: Ib161679f1f3b83787f90b8ef7dcf46d246bb7c57
1 parent cabb117 commit 30c7314

File tree

1 file changed

+0
-15
lines changed

1 file changed

+0
-15
lines changed

services/core/java/com/android/server/wm/ActivityRecord.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,6 @@
342342
import com.android.server.wm.WindowManagerService.H;
343343
import com.android.server.wm.utils.InsetUtils;
344344

345-
import com.google.android.collect.Sets;
346-
347345
import org.xmlpull.v1.XmlPullParserException;
348346

349347
import java.io.File;
@@ -2971,19 +2969,6 @@ private void finishActivityResults(int resultCode, Intent resultData,
29712969
}
29722970
mDisplayContent.prepareAppTransition(TRANSIT_CLOSE);
29732971

2974-
// When finishing the activity preemptively take the snapshot before the app window
2975-
// is marked as hidden and any configuration changes take place
2976-
// Note that RecentsAnimation will handle task snapshot while switching apps with
2977-
// the best capture timing (e.g. IME window capture),
2978-
// No need additional task capture while task is controlled by RecentsAnimation.
2979-
if (mAtmService.mWindowManager.mTaskSnapshotController != null
2980-
&& !task.isAnimatingByRecents()) {
2981-
final ArraySet<Task> tasks = Sets.newArraySet(task);
2982-
mAtmService.mWindowManager.mTaskSnapshotController.snapshotTasks(tasks);
2983-
mAtmService.mWindowManager.mTaskSnapshotController
2984-
.addSkipClosingAppSnapshotTasks(tasks);
2985-
}
2986-
29872972
// Tell window manager to prepare for this one to be removed.
29882973
setVisibility(false);
29892974

0 commit comments

Comments
 (0)