{"record":{"id":"6d98aba43c322cf1","repo":"CoplayDev/unity-mcp","slug":"preview-loading-timed-out","errorCode":null,"errorMessage":"Preview loading timed out.","messagePattern":"Preview loading timed out\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/NativePreviewGenerator.cs","lineNumber":254,"sourceCode":"\r\n        private async Task WaitAndWritePreviews(List<PreviewMetadata> objects, List<PreviewMetadata> generatedPreviews)\r\n        {\r\n            var initialObjectCount = objects.Count();\r\n            if (initialObjectCount == 0)\r\n                return;\r\n\r\n            await WaitAndWritePreviewIteration(objects, generatedPreviews);\r\n            var remainingObjectCount = objects.Count;\r\n\r\n            // First iteration may take longer to start loading objects\r\n            var firstIterationStartTime = EditorApplication.timeSinceStartup;\r\n            while (true)\r\n            {\r\n                if (remainingObjectCount < initialObjectCount)\r\n                    break;\r\n\r\n                if (EditorApplication.timeSinceStartup - firstIterationStartTime > InitialPreviewLoadingTimeoutSeconds)\r\n                    throw new Exception(\"Preview loading timed out.\");\r\n\r\n                await WaitAndWritePreviewIteration(objects, generatedPreviews);\r\n                remainingObjectCount = objects.Count;\r\n            }\r\n\r\n            if (remainingObjectCount == 0)\r\n                return;\r\n\r\n            while (true)\r\n            {\r\n                await WaitForEndOfFrame(1);\r\n                await WaitAndWritePreviewIteration(objects, generatedPreviews);\r\n\r\n                // If no more previews are being loaded, try one more time before quitting\r\n                if (objects.Count == remainingObjectCount)\r\n                {\r\n                    await WaitForEndOfFrame(1);\r\n                    await WaitAndWritePreviewIteration(objects, generatedPreviews);\r","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/NativePreviewGenerator.cs#L236-L272","documentation":"Thrown by NativePreviewGenerator.WaitAndWritePreviews (NativePreviewGenerator.cs:254) as a generic Exception after InitialPreviewLoadingTimeoutSeconds (10s) elapse without AssetPreview producing a single preview for the current batch (remainingObjectCount never drops below initialObjectCount). Unlike the Validate() errors, this is thrown inside GenerateImpl()'s try/catch, so it is captured into result.Exception with result.Success = false rather than propagating. It indicates Unity's AssetPreview subsystem is not delivering textures in time.","triggerScenarios":"Running the native generator with WaitForPreviews=true on assets whose previews AssetPreview never loads within 10 seconds. Common when target assets (large models/textures/materials) are still importing, when the AssetPreview texture cache is starved by a too-small ChunkSize, or under Unity Editor streams where AssetPreview loading is known to be inconsistent (see the code comment 'works inconsistently across Unity streams').","commonSituations":"Generating previews immediately after an AssetDatabase.Refresh / import that hasn't finished; very large asset sets; a Unity version with a flaky AssetPreview; running headless/batchmode where preview generation is unreliable.","solutions":["Let Unity finish importing the target assets before generating (wait for the import queue to drain), then re-run.","Enable ChunkedPreviewLoading with an adequate ChunkSize so the AssetPreview cache (sized ChunkSize*2) is not starved.","Switch to WaitForPreviews=false, which uses WritePreviewsWithoutWaiting and does not poll/timeout."],"exampleFix":"// before: waitForPreviews true, chunkSize 0 -> validation throws first; if set but previews stall, you hit the timeout\nvar s = new NativePreviewGenerationSettings { InputPaths = paths, OutputPath = out, ChunkSize = 5, WaitForPreviews = true };\n\n// after: non-blocking path avoids the polling timeout entirely\nvar s = new NativePreviewGenerationSettings { InputPaths = paths, OutputPath = out, ChunkSize = 100, WaitForPreviews = false };","handlingStrategy":"retry","validationCode":"// Nothing to validate pre-call; instead ensure assets are imported first.\nif (EditorApplication.isCompiling || EditorApplication.isUpdating)\n    throw new InvalidOperationException(\"Wait for Unity to finish importing/updating before generating previews.\");","typeGuard":null,"tryCatchPattern":"// GenerateImpl captures this into result.Exception; check the result, not an exception:\nvar result = await generator.Generate();\nif (!result.Success && result.Exception?.Message.Contains(\"timed out\") == true) { /* let imports finish, then retry or fall back to WaitForPreviews=false */ }","preventionTips":["Run generation only after AssetDatabase imports finish.","Enable ChunkedPreviewLoading with an adequate ChunkSize so the AssetPreview cache is not starved.","Fall back to WaitForPreviews=false (WritePreviewsWithoutWaiting) which does not poll and cannot hit this timeout."],"tags":["unity","asset-store-tools","preview-generation","assetpreview","timeout","runtime"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}