Skip to content

Commit b9fb49d

Browse files
authored
Merge branch 'master' into feature/additional-weapon-customization
2 parents 6570d07 + 49fb944 commit b9fb49d

129 files changed

Lines changed: 4908 additions & 20062 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Client/cefweb/CWebApp.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ namespace
5757
// Prevent Chromium from dropping privileges; required for elevated launches (see chromium/3960)
5858
commandLine->AppendSwitch("do-not-de-elevate");
5959

60-
// Must apply essential CEF switches regardless of WebCore availability
61-
commandLine->AppendSwitch("disable-gpu-compositing");
60+
// Enable external begin frame scheduling for MTA-controlled rendering
6261
commandLine->AppendSwitch("enable-begin-frame-scheduling");
6362
// Explicitly block account sign-in to avoid crashes when Google API keys are registered on the system
6463
commandLine->AppendSwitchWithValue("allow-browser-signin", "false");
@@ -71,6 +70,7 @@ namespace
7170
}
7271

7372
bool disableGpu = false;
73+
bool enableVideoAccel = true;
7474
if (g_pCore && IsReadablePointer(g_pCore, sizeof(void*)))
7575
{
7676
auto* cvars = g_pCore->GetCVars();
@@ -79,6 +79,8 @@ namespace
7979
bool gpuEnabled = true;
8080
cvars->Get("browser_enable_gpu", gpuEnabled);
8181
disableGpu = !gpuEnabled;
82+
83+
cvars->Get("browser_enable_video_acceleration", enableVideoAccel);
8284
}
8385
}
8486

@@ -92,13 +94,22 @@ namespace
9294
else
9395
{
9496
// In Wine, we generally want to try GPU (DXVK handles it well)
95-
// But disable-gpu-compositing is already set above which is key
9697
// If user hasn't explicitly disabled GPU in cvars, let it run
9798
}
9899
}
99100

100101
if (disableGpu)
102+
{
101103
commandLine->AppendSwitch("disable-gpu");
104+
// Also disable GPU compositing when GPU is disabled
105+
commandLine->AppendSwitch("disable-gpu-compositing");
106+
}
107+
108+
// Hardware video decoding - enable when GPU is enabled and video acceleration is requested
109+
if (!disableGpu && enableVideoAccel)
110+
{
111+
commandLine->AppendSwitch("enable-accelerated-video-decode");
112+
}
102113
}
103114
} // namespace
104115

Client/cefweb/CWebCore.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,20 @@ void CWebCore::DoEventQueuePulse()
440440
event.callback();
441441
}
442442

443-
// Invoke paint method if necessary on the main thread
443+
// Request new frames from CEF using external begin frame scheduling
444+
// This synchronizes CEF rendering with MTA's render loop, eliminating
445+
// the previous 250ms blocking wait in OnPaint
446+
for (auto& view : m_WebViews)
447+
{
448+
if (view->IsBeingDestroyed() || view->GetRenderingPaused())
449+
continue;
450+
451+
auto browser = view->GetCefBrowser();
452+
if (browser)
453+
browser->GetHost()->SendExternalBeginFrame();
454+
}
455+
456+
// Copy rendered data to D3D textures on the main thread
444457
for (auto& view : m_WebViews)
445458
{
446459
view->UpdateTexture();

Client/cefweb/CWebView.cpp

Lines changed: 145 additions & 221 deletions
Large diffs are not rendered by default.

Client/cefweb/CWebView.h

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
#include <cef3/cef/include/cef_values.h>
2525
#include <SString.h>
2626
#include <audiopolicy.h>
27-
#include <condition_variable>
2827
#include <functional>
2928
#include <memory>
3029
#include <mmdeviceapi.h>
3130
#include <mutex>
3231
#include <cstdint>
32+
#include <chrono>
3333
#define GetNextSibling(hwnd) GetWindow(hwnd, GW_HWNDNEXT) // Re-define the conflicting macro
3434
#define GetFirstChild(hwnd) GetTopWindow(hwnd)
3535

@@ -43,12 +43,6 @@ namespace WebViewAuth
4343
bool HandleInputFocus(CWebView*, CefRefPtr<CefListValue>, const bool);
4444
}
4545

46-
enum class ECefThreadState
47-
{
48-
Running = 0, // CEF thread is currently running
49-
Wait // CEF thread is waiting for the main thread
50-
};
51-
5246
class CWebView : public CWebViewInterface,
5347
private CefClient,
5448
private CefRenderHandler,
@@ -71,6 +65,7 @@ class CWebView : public CWebViewInterface,
7165
void SetWebBrowserEvents(CWebBrowserEventsInterface* pInterface);
7266
void ClearWebBrowserEvents(CWebBrowserEventsInterface* pInterface);
7367
void CloseBrowser();
68+
bool EnsureBrowserCreated(); // Lazy creation: creates browser on first use
7469
CefRefPtr<CefBrowser> GetCefBrowser() { return m_pWebView; };
7570

7671
bool IsBeingDestroyed() { return m_bBeingDestroyed; }
@@ -211,7 +206,6 @@ class CWebView : public CWebViewInterface,
211206
CefRefPtr<CefMenuModel> model) override;
212207

213208
private:
214-
void ResumeCefThread();
215209
void QueueBrowserEvent(const char* name, std::function<void(CWebBrowserEventsInterface*)>&& fn);
216210

217211
struct FEventTarget
@@ -270,29 +264,37 @@ class CWebView : public CWebViewInterface,
270264
CefRefPtr<CefBrowser> m_pWebView;
271265
CWebBrowserItem* m_pWebBrowserRenderItem;
272266

273-
std::atomic_bool m_bBeingDestroyed;
274-
bool m_bIsLocal;
275-
bool m_bIsRenderingPaused;
276-
bool m_bIsTransparent;
277-
POINT m_vecMousePosition;
278-
bool m_mouseButtonStates[3];
279-
SString m_CurrentTitle;
280-
float m_fVolume;
281-
std::map<SString, SString> m_Properties;
282-
bool m_bHasInputFocus;
283-
std::set<std::string> m_AjaxHandlers;
284-
std::shared_ptr<FEventTarget> m_pEventTarget;
267+
std::atomic_bool m_bBeingDestroyed;
268+
bool m_bIsLocal;
269+
bool m_bIsRenderingPaused;
270+
bool m_bIsTransparent;
271+
bool m_bBrowserCreated = false; // Lazy creation: tracks if CEF browser has been created
272+
SString m_strPendingURL; // Lazy creation: URL to load when browser is ready
273+
bool m_bPendingURLFilterEnabled = true;
274+
SString m_strPendingPostData;
275+
bool m_bPendingURLEncoded = true;
276+
POINT m_vecMousePosition;
277+
POINT m_vecPendingMousePosition; // Pending position for throttled mouse move
278+
bool m_bHasPendingMouseMove = false; // Whether there's a pending throttled mouse move
279+
std::chrono::steady_clock::time_point m_lastMouseMoveTime; // For mouse move throttling
280+
bool m_mouseButtonStates[3];
281+
SString m_CurrentTitle;
282+
float m_fVolume;
283+
std::map<SString, SString> m_Properties;
284+
bool m_bHasInputFocus;
285+
std::set<std::string> m_AjaxHandlers;
286+
std::shared_ptr<FEventTarget> m_pEventTarget;
285287

286288
struct
287289
{
288-
bool changed = false;
289-
std::mutex dataMutex;
290-
ECefThreadState cefThreadState = ECefThreadState::Running;
291-
std::condition_variable cefThreadCv;
292-
293-
const void* buffer;
294-
int width, height;
295-
CefRenderHandler::RectList dirtyRects;
290+
bool changed = false;
291+
std::mutex dataMutex;
292+
293+
// Main frame buffer - we now own this buffer (copied in OnPaint)
294+
std::unique_ptr<byte[]> buffer;
295+
size_t bufferSize = 0;
296+
int width = 0;
297+
int height = 0;
296298

297299
CefRect popupRect;
298300
bool popupShown = false;

Client/core/CClientVariables.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ void CClientVariables::LoadDefaults()
392392
DEFAULT("discord_rpc_share_data", false); // Consistent Rich Presence data sharing
393393
DEFAULT("discord_rpc_share_data_firsttime", false); // Display the user data sharing consent dialog box - for the first time
394394
DEFAULT("browser_enable_gpu", true); // Enable GPU in CEF? (allows stuff like WebGL to function)
395+
DEFAULT("browser_enable_video_acceleration", true); // Enable hardware video decoding in CEF?
395396
DEFAULT("process_cpu_affinity", true); // Set CPU 0 affinity to improve game performance and fix the known issue in single-threaded games
396397
DEFAULT("ask_before_disconnect", true); // Ask before disconnecting from a server
397398
DEFAULT("allow_steam_client", false); // Allow connecting with the local Steam client (to set GTA:SA ingame status)

Client/core/CCrashDumpWriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,13 +3240,15 @@ namespace
32403240
int iOut = -2;
32413241
if (*(DWORD*)dwThis != 0)
32423242
{
3243+
// clang-format off
32433244
_asm
32443245
{
32453246
mov ecx, dwThis
32463247
mov ecx, [ecx]
32473248
call dwFunc
32483249
mov iOut, eax
32493250
}
3251+
// clang-format on
32503252
}
32513253

32523254
return iOut;

Client/core/CGraphStats.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class CGraphStats : public CGraphStatsInterface
4545
bool m_bEnabled;
4646
std::map<SString, SGraphStatLine> m_LineList;
4747
TIMEUS m_StartTime;
48+
int m_iGraphSizeX;
4849
};
4950

5051
///////////////////////////////////////////////////////////////
@@ -112,16 +113,13 @@ void CGraphStats::AddTimingPoint(const char* szName)
112113
if (!IsEnabled())
113114
return;
114115

115-
CGraphicsInterface* pGraphics = g_pCore->GetGraphics();
116-
117-
std::uint32_t viewportWidth = pGraphics->GetViewportWidth();
118-
std::uint32_t sizeX = viewportWidth / 4; // one quarter of screen width
119-
120-
if (sizeX == 0)
116+
// Use the cached graph width from Draw(), which runs in MTA's render zone
117+
// with the real viewport. AddTimingPoint runs from OnBeginScene where GTA SA
118+
// may have set a smaller internal viewport (water reflections, radar, etc.).
119+
const int iSizeX = m_iGraphSizeX;
120+
if (iSizeX <= 0)
121121
return;
122122

123-
const int iSizeX = static_cast<int>(sizeX);
124-
125123
// Start of next frame?
126124
if (szName[0] == 0)
127125
{
@@ -162,7 +160,7 @@ void CGraphStats::AddTimingPoint(const char* szName)
162160
// Add new line
163161
MapSet(m_LineList, szName, SGraphStatLine());
164162
pLine = MapFind(m_LineList, szName);
165-
pLine->dataHistory.resize(sizeX);
163+
pLine->dataHistory.resize(iSizeX);
166164
pLine->iDataPos = 0;
167165
pLine->prevData = 0;
168166
pLine->strName = szName;
@@ -238,6 +236,14 @@ void CGraphStats::Draw()
238236

239237
const int iSizeX = static_cast<int>(sizeX);
240238

239+
// Cache the graph width for AddTimingPoint, which may run outside MTA's render zone
240+
// where GTA SA has temporarily changed the D3D viewport (water reflections, radar, etc.)
241+
if (m_iGraphSizeX != iSizeX)
242+
{
243+
m_LineList.clear();
244+
m_iGraphSizeX = iSizeX;
245+
}
246+
241247
originY = originY + sizeY + 30; // add graph height plus a little gap to the overall Y position
242248

243249
float fLineScale = 1 / 1000.f / rangeY * sizeY;

0 commit comments

Comments
 (0)