From 5eec36b43aad07ab5fb5e4eef94f1469bc7da1b4 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sat, 7 May 2022 20:23:35 -0400
Subject: [PATCH] Speed up web plugin a bit

---
 indra/llplugin/llplugininstance.cpp          |  6 +++++-
 indra/llplugin/llpluginprocesschild.cpp      | 13 ++++++++++++-
 indra/llplugin/llpluginprocessparent.cpp     |  4 ++++
 indra/media_plugins/cef/media_plugin_cef.cpp | 18 ++++++++++++------
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/indra/llplugin/llplugininstance.cpp b/indra/llplugin/llplugininstance.cpp
index 773dcf7cdaa..9e9aac98f17 100644
--- a/indra/llplugin/llplugininstance.cpp
+++ b/indra/llplugin/llplugininstance.cpp
@@ -137,7 +137,9 @@ void LLPluginInstance::sendMessage(const std::string &message)
 {
 	if(mPluginSendMessageFunction)
 	{
+#ifdef SHOW_DEBUG
 		LL_DEBUGS("Plugin") << "sending message to plugin: \"" << message << "\"" << LL_ENDL;
+#endif
 		mPluginSendMessageFunction(message.c_str(), &mPluginUserData);
 	}
 	else
@@ -172,7 +174,9 @@ void LLPluginInstance::receiveMessage(const char *message_string)
 {
 	if(mOwner)
 	{
-		LL_DEBUGS("Plugin") << "processing incoming message: \"" << message_string << "\"" << LL_ENDL;		
+#if SHOW_DEBUG
+		LL_DEBUGS("Plugin") << "processing incoming message: \"" << message_string << "\"" << LL_ENDL;
+#endif
 		mOwner->receivePluginMessage(message_string);
 	}
 	else
diff --git a/indra/llplugin/llpluginprocesschild.cpp b/indra/llplugin/llpluginprocesschild.cpp
index d93ec8cf4b9..e5ae0dd34fb 100644
--- a/indra/llplugin/llpluginprocesschild.cpp
+++ b/indra/llplugin/llpluginprocesschild.cpp
@@ -320,7 +320,9 @@ void LLPluginProcessChild::sendMessageToPlugin(const LLPluginMessage &message)
 	{
 		std::string buffer = message.generate();
 
+#ifdef SHOW_DEBUG
 		LL_DEBUGS("Plugin") << "Sending to plugin: " << buffer << LL_ENDL;
+#endif
 		LLTimer elapsed;
 
 		mInstance->sendMessage(buffer);
@@ -337,7 +339,9 @@ void LLPluginProcessChild::sendMessageToParent(const LLPluginMessage &message)
 {
 	std::string buffer = message.generate();
 
+#if SHOW_DEBUG
 	LL_DEBUGS("Plugin") << "Sending to parent: " << buffer << LL_ENDL;
+#endif
 
 	writeMessageRaw(buffer);
 }
@@ -345,8 +349,9 @@ void LLPluginProcessChild::sendMessageToParent(const LLPluginMessage &message)
 void LLPluginProcessChild::receiveMessageRaw(const std::string &message)
 {
 	// Incoming message from the TCP Socket
-
+#if SHOW_DEBUG
 	LL_DEBUGS("Plugin") << "Received from parent: " << message << LL_ENDL;
+#endif
 
 	// Decode this message
 	LLPluginMessage parsed;
@@ -485,7 +490,9 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message)
 /* virtual */
 void LLPluginProcessChild::receivePluginMessage(const std::string &message)
 {
+#if SHOW_DEBUG
 	LL_DEBUGS("Plugin") << "Received from plugin: " << message << LL_ENDL;
+#endif
 
 	if (mBlockingRequest)
 	{
@@ -568,7 +575,9 @@ void LLPluginProcessChild::receivePluginMessage(const std::string &message)
 
 	if (passMessage)
 	{
+#if SHOW_DEBUG
 		LL_DEBUGS("Plugin") << "Passing through to parent: " << message << LL_ENDL;
+#endif
 		writeMessageRaw(message);
 	}
 
@@ -589,7 +598,9 @@ void LLPluginProcessChild::receivePluginMessage(const std::string &message)
 
 void LLPluginProcessChild::setState(EState state)
 {
+#if SHOW_DEBUG
 	LL_DEBUGS("Plugin") << "setting state to " << state << LL_ENDL;
+#endif
 	mState = state;
 };
 
diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp
index 78f6edc1211..1a09c2b3ea9 100644
--- a/indra/llplugin/llpluginprocessparent.cpp
+++ b/indra/llplugin/llpluginprocessparent.cpp
@@ -120,7 +120,9 @@ LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner):
 
 LLPluginProcessParent::~LLPluginProcessParent()
 {
+#ifdef SHOW_DEBUG
 	LL_DEBUGS("Plugin") << "destructor" << LL_ENDL;
+#endif
     if (pProcessCreationThread)
     {
         if (!pProcessCreationThread->isStopped())
@@ -1295,7 +1297,9 @@ std::string LLPluginProcessParent::getPluginVersion(void)
 
 void LLPluginProcessParent::setState(EState state)
 {
+#ifdef SHOW_DEBUG
 	LL_DEBUGS("Plugin") << "setting state to " << state << LL_ENDL;
+#endif
 	mState = state; 
 };
 
diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp
index 0511952fee6..00b0dafa2b3 100644
--- a/indra/media_plugins/cef/media_plugin_cef.cpp
+++ b/indra/media_plugins/cef/media_plugin_cef.cpp
@@ -862,17 +862,23 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
 					mCEFLib->mouseButton(btn, dullahan::ME_MOUSE_DOWN, x, y);
 					mCEFLib->setFocus();
 
-					std::stringstream str;
-					str << "Mouse down at = " << x << ", " << y;
-					postDebugMessage(str.str());
+					if(mEnableMediaPluginDebugging)
+					{
+						std::stringstream str;
+						str << "Mouse down at = " << x << ", " << y;
+						postDebugMessage(str.str());
+					}
 				}
 				else if (event == "up" && button == 0)
 				{
 					mCEFLib->mouseButton(btn, dullahan::ME_MOUSE_UP, x, y);
 
-					std::stringstream str;
-					str << "Mouse up at = " << x << ", " << y;
-					postDebugMessage(str.str());
+					if (mEnableMediaPluginDebugging)
+					{
+						std::stringstream str;
+						str << "Mouse up at = " << x << ", " << y;
+						postDebugMessage(str.str());
+					}
 				}
 				else if (event == "double_click")
 				{
-- 
GitLab