From 7e374c932419e06bbc02418218ea2a3330e359e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 4 Jan 2023 13:48:40 +0100 Subject: [PATCH] Address feedback, more fixes --- Common/GPU/Vulkan/VulkanRenderManager.cpp | 6 ++++-- Common/Thread/ThreadUtil.h | 2 +- Core/Dialog/PSPSaveDialog.cpp | 2 ++ Core/SaveState.cpp | 3 +-- Core/WebServer.cpp | 6 ++++++ android/jni/app-android.cpp | 8 +++++--- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index f26139ddd5..974e6899e6 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -115,15 +115,17 @@ bool VKRGraphicsPipeline::Create(VulkanContext *vulkan, VkRenderPass compatibleR pipe.basePipelineIndex = 0; pipe.subpass = 0; + INFO_LOG(G3D, "Creating pipeline... rpType: %08x sampleBits: %d (%s)", (u32)rpType, (u32)sampleCount, tag_.c_str()); + double start = time_now_d(); VkPipeline vkpipeline; VkResult result = vkCreateGraphicsPipelines(vulkan->GetDevice(), desc->pipelineCache, 1, &pipe, nullptr, &vkpipeline); double taken_ms = (time_now_d() - start) * 1000.0; if (taken_ms < 0.1) { - DEBUG_LOG(G3D, "Pipeline creation time: %0.2f ms (fast) rpType: %08x sampleBits: %d\n(%s)", taken_ms, (u32)rpType, (u32)sampleCount, tag_.c_str()); + DEBUG_LOG(G3D, "Pipeline creation time: %0.2f ms (fast) rpType: %08x sampleBits: %d (%s)", taken_ms, (u32)rpType, (u32)sampleCount, tag_.c_str()); } else { - INFO_LOG(G3D, "Pipeline creation time: %0.2f ms rpType: %08x sampleBits: %d\n(%s)", taken_ms, (u32)rpType, (u32)sampleCount, tag_.c_str()); + INFO_LOG(G3D, "Pipeline creation time: %0.2f ms rpType: %08x sampleBits: %d (%s)", taken_ms, (u32)rpType, (u32)sampleCount, tag_.c_str()); } bool success = true; diff --git a/Common/Thread/ThreadUtil.h b/Common/Thread/ThreadUtil.h index ee4b461401..d6c6e60c84 100644 --- a/Common/Thread/ThreadUtil.h +++ b/Common/Thread/ThreadUtil.h @@ -2,7 +2,7 @@ #include -// Note that the string pointed to must be have a lifetime until the end of the thread, +// Note that the string pointed to must have a lifetime until the end of the thread, // for AssertCurrentThreadName to work. void SetCurrentThreadName(const char *threadName); void AssertCurrentThreadName(const char *threadName); diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 8e0bfcb1ba..a1ef203606 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -1210,6 +1210,8 @@ void PSPSaveDialog::JoinIOThread() { static void DoExecuteIOAction(PSPSaveDialog *dialog) { SetCurrentThreadName("SaveIO"); + + AndroidJNIThreadContext jniContext; dialog->ExecuteIOAction(); } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index d9282037a6..c28cb190a1 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -165,8 +165,7 @@ namespace SaveState compressThread_ = std::thread([=]{ SetCurrentThreadName("SaveStateCompress"); - AndroidJNIThreadContext jniContext; - + // Should do no I/O, so no JNI thread context needed. Compress(*result, *state, *base); }); } diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index 701d4f070c..3de0fabc7b 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -212,6 +212,8 @@ static void DiscHandler(const http::Request &request, const Path &filename) { } static void HandleListing(const http::Request &request) { + AndroidJNIThreadContext jniContext; + request.WriteHttpResponseHeader("1.0", 200, -1, "text/plain"); request.Out()->Printf("/\n"); if (serverFlags & (int)WebServerFlags::DISCS) { @@ -269,6 +271,8 @@ static void RedirectToDebugger(const http::Request &request) { } static void HandleFallback(const http::Request &request) { + AndroidJNIThreadContext jniContext; + if (serverFlags & (int)WebServerFlags::DISCS) { Path filename = LocalFromRemotePath(request.resource()); if (!filename.empty()) { @@ -293,6 +297,8 @@ static void HandleFallback(const http::Request &request) { } static void ForwardDebuggerRequest(const http::Request &request) { + AndroidJNIThreadContext jniContext; + if (serverFlags & (int)WebServerFlags::DEBUGGER) { // Check if this is a websocket request... std::string upgrade; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 276e4c3f4a..15290ddf43 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -50,6 +50,9 @@ struct JNIEnv {}; #define JNI_VERSION_1_6 16 #endif +#include "Common/Log.h" +#include "Common/LogReporting.h" + #include "Common/Net/Resolve.h" #include "android/jni/AndroidAudio.h" #include "Common/GPU/OpenGL/GLCommon.h" @@ -71,7 +74,6 @@ struct JNIEnv {}; #include "Common/Data/Text/Parsers.h" #include "Common/VR/PPSSPPVR.h" -#include "Common/Log.h" #include "Common/GraphicsContext.h" #include "Common/StringUtils.h" #include "Common/TimeUtil.h" @@ -264,7 +266,6 @@ void Android_AttachThreadToJNI() { JNIEnv *env; int status = gJvm->GetEnv((void **)&env, JNI_VERSION_1_6); if (status < 0) { - // TODO: We should have a version of getEnv that doesn't allow auto-attach. INFO_LOG(SYSTEM, "Attaching thread '%s' (not already attached) to JNI.", GetCurrentThreadName()); JavaVMAttachArgs args{}; args.version = JNI_VERSION_1_6; @@ -272,7 +273,8 @@ void Android_AttachThreadToJNI() { status = gJvm->AttachCurrentThread(&env, &args); if (status < 0) { - // bad, but wh + // bad, but what can we do other than report.. + ERROR_LOG_REPORT_ONCE(threadAttachFail, SYSTEM, "Failed to attach thread %s to JNI.", GetCurrentThreadName()); } } else { WARN_LOG(SYSTEM, "Thread %s was already attached to JNI.", GetCurrentThreadName());