Remove Useless Render Frame Skip Check

This commit is contained in:
copecone committed 2026-09-17 10:41:26 +09:00
1 parent 8014975c81
commit 363130e87b
3 files changed
-84

No files matched your search

-54
View File
@@ -15,7 +15,6 @@ using ADOFAIRenderer.Util.FFmpeg;
using FFmpeg.AutoGen;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Utils;
using UnityEngine;
using UnityEngine.Rendering;
using Random = UnityEngine.Random;
@@ -73,7 +72,6 @@ internal class RenderManager : MonoBehaviour
public static bool IsCapturingActive => Instance && Instance.IsCapturing;
public const int MaxQueuedFrames = 64;
public const int MaxRenderRetry = 64;
// Statistics
public long framesSent;
@@ -100,8 +98,6 @@ internal class RenderManager : MonoBehaviour
private AudioSyncCalculator SyncCalculator { get; set; } = null!;
private FrameReader? _frameReader;
public bool renderCheck = true;
public int skipCount;
public long frameCountForVideo;
public long lastVideoFrameIndex = -1;
@@ -277,52 +273,6 @@ internal class RenderManager : MonoBehaviour
public void OnPreUpdate()
{
if (!IsRendering) return;
// [Retry logic when frame rendering is skipped due to lag (ported from original mod)]
if (renderCheck && IsCapturing)
{
if (skipCount < MaxRenderRetry)
{
Melon<RenderMod>.Logger.Warning($"[Render Skipped] Frame {frameCount} rendering missed. Retrying... (Attempt {skipCount + 1}/{MaxRenderRetry})");
skipCount++;
Time.timeScale = 0f; // Pause progress time (retry)
return; // Wait without advancing update
}
// If retries exceed limit, supply a fallback black frame to prevent freezing the pipeline
Melon<RenderMod>.Logger.Error($"[Render Skipped] Frame {frameCount} rendering failed after 60 retries. Supplying black frame.");
var currentFrame = frameCountForVideo++;
var renderFPS = Configuration.RenderFPS;
var videoFPS = Configuration.VideoFPS;
var effectiveVideoFps = Math.Min(videoFPS, renderFPS);
var videoFrameIndex = (long)(currentFrame * effectiveVideoFps / renderFPS);
if (videoFrameIndex > lastVideoFrameIndex)
{
lastVideoFrameIndex = videoFrameIndex;
lastRequestedVideoFrameIndex = videoFrameIndex;
var byteSize = Configuration.RenderWidth * Configuration.RenderHeight * 4;
var blackFrame = ArrayPool<byte>.Shared.Rent(byteSize);
Array.Clear(blackFrame, 0, byteSize);
lock (ImageQueue)
{
ImageQueue[videoFrameIndex] = new CapturedFrame
{
ManagedBuffer = blackFrame,
Length = byteSize
};
}
FrameAvailableEvent.Set();
}
renderCheck = false; // Allow progress
}
skipCount = 0;
renderCheck = true; // Reset for next frame check
frameCount++;
}
@@ -344,8 +294,6 @@ internal class RenderManager : MonoBehaviour
{
if (!IsCapturing || !texture) return;
renderCheck = false; // Normal rendering complete for this frame
// [Backpressure Throttling]
isThrottling = false;
@@ -511,8 +459,6 @@ internal class RenderManager : MonoBehaviour
frameCountForVideo = 0;
lastVideoFrameIndex = -1;
lastRequestedVideoFrameIndex = -1;
renderCheck = true;
skipCount = 0;
endRequested = false;
endSuccessful = false;
FrameAvailableEvent.Reset();