From adc5f3cb7819a672c37a73f0c4cd850df536e9da Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Fri, 24 Jul 2026 14:33:11 +0300 Subject: #5796 Add CEF remote debugging port debug setting Increment CEF remote debugging port for each new media plugin instance CEFRemoteDebuggingPort should not persist between sessions --- indra/llplugin/llpluginclassmedia.cpp | 34 ++++++++++++++++++++++++++++++++++ indra/llplugin/llpluginclassmedia.h | 7 +++++++ indra/llplugin/llpluginprocessparent.h | 2 ++ 3 files changed, 43 insertions(+) (limited to 'indra/llplugin') diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index 9a1f408b34..da5fe08b13 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -41,6 +41,8 @@ extern bool gHiDPISupport; #endif static int LOW_PRIORITY_TEXTURE_SIZE_DEFAULT = 256; +static const U32 MIN_DEBUG_PORT = 1024; +static const U32 MAX_DEBUG_PORT = 65535; static int nextPowerOf2( int value ) { @@ -963,6 +965,34 @@ void LLPluginClassMedia::showPageSource() sendMessage(message); } + +static U32 assignCefDebuggingPort() +{ + U32 base_port = gSavedSettings.getU32("CEFRemoteDebuggingPort"); + if (base_port == 0) + { + return 0; + } + base_port = llclamp(base_port, MIN_DEBUG_PORT, MAX_DEBUG_PORT); + + static U32 last_base_port = 0; + static U32 offset = 0; + if (base_port != last_base_port) + { + last_base_port = base_port; + offset = 0; + } + + U32 new_port = base_port + offset; + if (new_port > MAX_DEBUG_PORT) + { + return 0; + } + + ++offset; + return new_port; +} + void LLPluginClassMedia::setUserDataPath(const std::string &user_data_path_cache, const std::string &username, const std::string &user_data_path_cef_log) @@ -974,6 +1004,10 @@ void LLPluginClassMedia::setUserDataPath(const std::string &user_data_path_cache bool cef_verbose_log = gSavedSettings.getBOOL("CefVerboseLog"); message.setValueBoolean("cef_verbose_log", cef_verbose_log); + + U32 cef_remote_debugging_port = assignCefDebuggingPort(); + message.setValueU32("cef_remote_debugging_port", cef_remote_debugging_port); + mCefRemoteDebuggingPort = cef_remote_debugging_port; sendMessage(message); } diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 40f6295e55..1125d530f4 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -165,6 +165,11 @@ public: std::string getPluginVersion() { return mPlugin?mPlugin->getPluginVersion():std::string(""); }; + int getProcessID() { return mPlugin ? (int)mPlugin->getProcessID() : 0; }; + + // 0 means remote debugging is disabled for this plugin instance. + U32 getCefRemoteDebuggingPort() const { return mCefRemoteDebuggingPort; }; + bool getDisableTimeout() { return mPlugin?mPlugin->getDisableTimeout():false; }; void setDisableTimeout(bool disable) { if(mPlugin) mPlugin->setDisableTimeout(disable); }; @@ -434,6 +439,8 @@ protected: F64 mSleepTime; + U32 mCefRemoteDebuggingPort {0}; + bool mCanUndo; bool mCanRedo; bool mCanCut; diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h index ea604ca8d7..3cfd4211d7 100644 --- a/indra/llplugin/llpluginprocessparent.h +++ b/indra/llplugin/llpluginprocessparent.h @@ -119,6 +119,8 @@ public: bool getDisableTimeout() { return mDisableTimeout; }; void setDisableTimeout(bool disable) { mDisableTimeout = disable; }; + LLProcess::id getProcessID() const { return mProcess ? mProcess->getProcessID() : 0; } + void setLaunchTimeout(F32 timeout) { mPluginLaunchTimeout = timeout; }; void setLockupTimeout(F32 timeout) { mPluginLockupTimeout = timeout; }; -- cgit v1.3