Merge "Support dump gfxinfo reset for process' without a Window"

This commit is contained in:
TreeHugger Robot
2021-10-04 20:34:24 +00:00
committed by Android (Google) Code Review
11 changed files with 45 additions and 83 deletions

View File

@@ -4578,8 +4578,7 @@ public final class ActivityThread extends ClientTransactionHandler
private void handleDumpGfxInfo(DumpComponentInfo info) {
try {
nDumpGraphicsInfo(info.fd.getFileDescriptor());
WindowManagerGlobal.getInstance().dumpGfxInfo(info.fd.getFileDescriptor(), info.args);
ThreadedRenderer.handleDumpGfxInfo(info.fd.getFileDescriptor(), info.args);
} catch (Exception e) {
Log.w(TAG, "Caught exception from dumpGfxInfo()", e);
} finally {
@@ -7905,6 +7904,5 @@ public final class ActivityThread extends ClientTransactionHandler
// ------------------ Regular JNI ------------------------
private native void nPurgePendingResources();
private native void nDumpGraphicsInfo(FileDescriptor fd);
private native void nInitZygoteChildHeapProfiling();
}

View File

@@ -609,11 +609,7 @@ public final class ThreadedRenderer extends HardwareRenderer {
return mHeight;
}
/**
* Outputs extra debugging information in the specified file descriptor.
*/
void dumpGfxInfo(PrintWriter pw, FileDescriptor fd, String[] args) {
pw.flush();
private static int dumpArgsToFlags(String[] args) {
// If there's no arguments, eg 'dumpsys gfxinfo', then dump everything.
// If there's a targetted package, eg 'dumpsys gfxinfo com.android.systemui', then only
// dump the summary information
@@ -631,7 +627,21 @@ public final class ThreadedRenderer extends HardwareRenderer {
break;
}
}
dumpProfileInfo(fd, flags);
return flags;
}
/** @hide */
public static void handleDumpGfxInfo(FileDescriptor fd, String[] args) {
dumpGlobalProfileInfo(fd, dumpArgsToFlags(args));
WindowManagerGlobal.getInstance().dumpGfxInfo(fd, args);
}
/**
* Outputs extra debugging information in the specified file descriptor.
*/
void dumpGfxInfo(PrintWriter pw, FileDescriptor fd, String[] args) {
pw.flush();
dumpProfileInfo(fd, dumpArgsToFlags(args));
}
Picture captureRenderingCommands() {

View File

@@ -21,7 +21,6 @@
#include <unistd.h>
#include <bionic/malloc.h>
#include <android/graphics/renderthread.h>
namespace android {
@@ -30,12 +29,6 @@ static void android_app_ActivityThread_purgePendingResources(JNIEnv* env, jobjec
mallopt(M_PURGE, 0);
}
static void
android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor) {
int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
ARenderThread_dumpGraphicsMemory(fd);
}
static void android_app_ActivityThread_initZygoteChildHeapProfiling(JNIEnv* env, jobject clazz) {
android_mallopt(M_INIT_ZYGOTE_CHILD_PROFILING, nullptr, 0);
}
@@ -44,8 +37,6 @@ static JNINativeMethod gActivityThreadMethods[] = {
// ------------ Regular JNI ------------------
{ "nPurgePendingResources", "()V",
(void*) android_app_ActivityThread_purgePendingResources },
{ "nDumpGraphicsInfo", "(Ljava/io/FileDescriptor;)V",
(void*) android_app_ActivityThread_dumpGraphics },
{ "nInitZygoteChildHeapProfiling", "()V",
(void*) android_app_ActivityThread_initZygoteChildHeapProfiling }
};

View File

@@ -820,6 +820,13 @@ public class HardwareRenderer {
return nLoadSystemProperties(mNativeProxy);
}
/**
* @hide
*/
public static void dumpGlobalProfileInfo(FileDescriptor fd, @DumpFlags int dumpFlags) {
nDumpGlobalProfileInfo(fd, dumpFlags);
}
/**
* @hide
*/
@@ -1390,6 +1397,8 @@ public class HardwareRenderer {
private static native void nDumpProfileInfo(long nativeProxy, FileDescriptor fd,
@DumpFlags int dumpFlags);
private static native void nDumpGlobalProfileInfo(FileDescriptor fd, @DumpFlags int dumpFlags);
private static native void nAddRenderNode(long nativeProxy, long rootRenderNode,
boolean placeFront);

View File

@@ -272,7 +272,6 @@ cc_defaults {
"apex/android_bitmap.cpp",
"apex/android_canvas.cpp",
"apex/jni_runtime.cpp",
"apex/renderthread.cpp",
],
},
host: {

View File

@@ -1,34 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_GRAPHICS_RENDERTHREAD_H
#define ANDROID_GRAPHICS_RENDERTHREAD_H
#include <cutils/compiler.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/**
* Dumps a textual representation of the graphics stats for this process.
* @param fd The file descriptor that the available graphics stats will be appended to. The
* function requires a valid fd, but does not persist or assume ownership of the fd
* outside the scope of this function.
*/
ANDROID_API void ARenderThread_dumpGraphicsMemory(int fd);
__END_DECLS
#endif // ANDROID_GRAPHICS_RENDERTHREAD_H

View File

@@ -1,25 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "android/graphics/renderthread.h"
#include <renderthread/RenderProxy.h>
using namespace android;
void ARenderThread_dumpGraphicsMemory(int fd) {
uirenderer::renderthread::RenderProxy::dumpGraphicsMemory(fd);
}

View File

@@ -379,6 +379,13 @@ static void android_view_ThreadedRenderer_dumpProfileInfo(JNIEnv* env, jobject c
proxy->dumpProfileInfo(fd, dumpFlags);
}
static void android_view_ThreadedRenderer_dumpGlobalProfileInfo(JNIEnv* env, jobject clazz,
jobject javaFileDescriptor,
jint dumpFlags) {
int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
RenderProxy::dumpGraphicsMemory(fd, true, dumpFlags & DumpFlags::Reset);
}
static void android_view_ThreadedRenderer_addRenderNode(JNIEnv* env, jobject clazz,
jlong proxyPtr, jlong renderNodePtr, jboolean placeFront) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
@@ -910,6 +917,8 @@ static const JNINativeMethod gMethods[] = {
{"nNotifyFramePending", "(J)V", (void*)android_view_ThreadedRenderer_notifyFramePending},
{"nDumpProfileInfo", "(JLjava/io/FileDescriptor;I)V",
(void*)android_view_ThreadedRenderer_dumpProfileInfo},
{"nDumpGlobalProfileInfo", "(Ljava/io/FileDescriptor;I)V",
(void*)android_view_ThreadedRenderer_dumpGlobalProfileInfo},
{"setupShadersDiskCache", "(Ljava/lang/String;Ljava/lang/String;)V",
(void*)android_view_ThreadedRenderer_setupShadersDiskCache},
{"nAddRenderNode", "(JJZ)V", (void*)android_view_ThreadedRenderer_addRenderNode},

View File

@@ -1,4 +1,4 @@
LIBHWUI {
LIBHWUI { # platform-only /* HWUI isn't current a module, so all of these are still platform-only */
global:
/* listing of all C APIs to be exposed by libhwui to consumers outside of the module */
ABitmap_getInfoFromJava;
@@ -39,7 +39,6 @@ LIBHWUI {
ARegionIterator_next;
ARegionIterator_getRect;
ARegionIterator_getTotalBounds;
ARenderThread_dumpGraphicsMemory;
local:
*;
};

View File

@@ -257,10 +257,15 @@ uint32_t RenderProxy::frameTimePercentile(int percentile) {
});
}
void RenderProxy::dumpGraphicsMemory(int fd, bool includeProfileData) {
void RenderProxy::dumpGraphicsMemory(int fd, bool includeProfileData, bool resetProfile) {
if (RenderThread::hasInstance()) {
auto& thread = RenderThread::getInstance();
thread.queue().runSync([&]() { thread.dumpGraphicsMemory(fd, includeProfileData); });
thread.queue().runSync([&]() {
thread.dumpGraphicsMemory(fd, includeProfileData);
if (resetProfile) {
thread.globalProfileData()->reset();
}
});
}
}

View File

@@ -108,7 +108,8 @@ public:
// Not exported, only used for testing
void resetProfileInfo();
uint32_t frameTimePercentile(int p);
static void dumpGraphicsMemory(int fd, bool includeProfileData = true);
static void dumpGraphicsMemory(int fd, bool includeProfileData = true,
bool resetProfile = false);
static void getMemoryUsage(size_t* cpuUsage, size_t* gpuUsage);
static void rotateProcessStatsBuffer();