{"record":{"id":"c1cc05df51614566","repo":"EllanJiang/GameFramework","slug":"verify-resource-count-per-frame-is-invalid","errorCode":null,"errorMessage":"Verify resource count per frame is invalid.","messagePattern":"Verify resource count per frame is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceVerifier.cs","lineNumber":130,"sourceCode":"            /// </summary>\n            public void Shutdown()\n            {\n                m_VerifyInfos.Clear();\n                m_LoadReadWriteVersionListComplete = false;\n                m_VerifyResourceLengthPerFrame = 0;\n                m_VerifyResourceIndex = 0;\n                m_FailureFlag = false;\n            }\n\n            /// <summary>\n            /// 校验资源。\n            /// </summary>\n            /// <param name=\"verifyResourceLengthPerFrame\">每帧至少校验资源的大小，以字节为单位。</param>\n            public void VerifyResources(int verifyResourceLengthPerFrame)\n            {\n                if (verifyResourceLengthPerFrame < 0)\n                {\n                    throw new GameFrameworkException(\"Verify resource count per frame is invalid.\");\n                }\n\n                if (m_ResourceManager.m_ResourceHelper == null)\n                {\n                    throw new GameFrameworkException(\"Resource helper is invalid.\");\n                }\n\n                if (string.IsNullOrEmpty(m_ResourceManager.m_ReadWritePath))\n                {\n                    throw new GameFrameworkException(\"Read-write path is invalid.\");\n                }\n\n                m_VerifyResourceLengthPerFrame = verifyResourceLengthPerFrame;\n                m_ResourceManager.m_ResourceHelper.LoadBytes(Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_ReadWritePath, LocalVersionListFileName)), new LoadBytesCallbacks(OnLoadReadWriteVersionListSuccess, OnLoadReadWriteVersionListFailure), null);\n            }\n\n            private bool VerifyResource(VerifyInfo verifyInfo)\n            {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceVerifier.cs#L112-L148","documentation":"ResourceVerifier.VerifyResources throws this when verifyResourceLengthPerFrame is negative. This parameter bounds how many bytes are verified per frame; a negative value is meaningless and rejected up front as an invalid argument.","triggerScenarios":"Calling VerifyResources(-1) or passing any negative per-frame byte budget, e.g. from a config value that was mis-parsed or defaulted to -1 as a 'disabled' sentinel.","commonSituations":"Config files where -1 means 'unlimited' by convention elsewhere but not here; UI sliders that can be dragged below 0; uninitialized int fields defaulting to -1.","solutions":["Pass a non-negative value, e.g. VerifyResources(1024 * 1024) for 1MB per frame.","Clamp the value before calling: verifyResourceLengthPerFrame = Math.Max(0, value).","Fix the config/default that produced the negative number."],"exampleFix":"// before\nm_ResourceManager.VerifyResources(userConfig.verifyBytesPerFrame); // may be -1\n// after\nint bytes = Math.Max(0, userConfig.verifyBytesPerFrame);\nm_ResourceManager.VerifyResources(bytes);","handlingStrategy":"validation","validationCode":"// C#\nif (verifyResourceLengthPerFrame < 0)\n{\n    throw new ArgumentException(\"verifyResourceLengthPerFrame must be >= 0\", nameof(verifyResourceLengthPerFrame));\n}\nm_ResourceManager.VerifyResources(verifyResourceLengthPerFrame);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp or assert per-frame byte budgets before calling VerifyResources.","Do not use -1 as an 'unlimited' sentinel in configs that feed this API.","Validate config values at load time so bad numbers never reach the API."],"tags":["gameframework","resource-verifier","argument-validation","negative-value"],"backgroundTag":"invalid-argument-value","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}