{"record":{"id":"7f89d881a1e4d0be","repo":"stride3d/stride","slug":"invalid-video-resolution","errorCode":null,"errorMessage":"Invalid video resolution.","messagePattern":"Invalid video resolution\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Video/VideoTexture.cs","lineNumber":34,"sourceCode":"        /// <summary>\n        /// Effect used to copy the <see cref=\"decoderOutputTexture\"/> into the <see cref=\"renderTargetTexture\"/>.\n        /// </summary>\n        private EffectInstance effectDecoderTextureCopy;\n        /// <summary>\n        /// Effect used to create mipmap inside the <see cref=\"renderTargetTexture\"/>\n        /// </summary>\n        private EffectInstance effectTexture2DCopy;\n\n        private Texture originalTargetTexture;\n        private Texture renderTargetTexture;\n\n        private SamplerState minMagLinearMipPointSampler;\n\n        public VideoTexture(GraphicsDevice graphicsDevice, IServiceRegistry serviceRegistry, int width, int height, int maxMipMapCount)\n        {\n            if (width <= 0 || height <= 0)\n            {\n                throw new InvalidOperationException(\"Invalid video resolution.\");\n            }\n\n            if (maxMipMapCount < 0)\n            {\n                throw new InvalidOperationException(\"A negative number of mip maps is not allowed.\");\n            }\n\n            var effectSystem = serviceRegistry.GetSafeServiceAs<EffectSystem>();\n\n            // We want to sample mip maps using point filtering (to make sure nothing bleeds between mip maps).\n            minMagLinearMipPointSampler = SamplerState.New(graphicsDevice, new SamplerStateDescription(TextureFilter.MinMagLinearMipPoint, TextureAddressMode.Clamp));\n\n            // Allocate the effect for copying decoder output texture to our normal render texture\n            effectDecoderTextureCopy = new EffectInstance(effectSystem.LoadEffect(\"SpriteEffectExtTexture\").WaitForResult());\n            effectDecoderTextureCopy.Parameters.Set(SpriteEffectExtTextureKeys.Gamma, 2.2f);\n            effectDecoderTextureCopy.Parameters.Set(SpriteEffectExtTextureKeys.MipLevel, 0.0f);\n            effectDecoderTextureCopy.Parameters.Set(SpriteEffectExtTextureKeys.Sampler, minMagLinearMipPointSampler);\n            effectDecoderTextureCopy.UpdateEffect(graphicsDevice);","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Video/VideoTexture.cs#L16-L52","documentation":"The VideoTexture constructor validates that width and height are strictly positive before creating the GPU texture and mip chain. A non-positive dimension cannot describe a valid texture, so the constructor fails fast with InvalidOperationException instead of producing a broken GraphicsResource.","triggerScenarios":"Constructing VideoTexture (directly or via VideoInstance.AllocateVideoTexture) with width <= 0 or height <= 0 — typically because the underlying video/texture metadata reported zero-size dimensions before the stream was opened or decoded.","commonSituations":"Querying video size before the media is loaded, so width/height default to 0; a corrupted or unsupported video file whose dimensions read as 0; passing unvalidated configuration values as resolution.","solutions":["Load/open the video first so real dimensions are known, then allocate the texture.","Validate width and height are > 0 before constructing VideoTexture and fall back to sane defaults (e.g. 1280x720) otherwise.","Check the source video file: re-encode or replace it if its metadata reports a zero resolution."],"exampleFix":"// before\nvideoInstance.AllocateVideoTexture(videoWidth, videoHeight); // videoWidth = 0 before load\n\n// after\nif (videoWidth > 0 && videoHeight > 0)\n    videoInstance.AllocateVideoTexture(videoWidth, videoHeight);\nelse\n    videoInstance.AllocateVideoTexture(1280, 720); // fallback until real size known","handlingStrategy":"validation","validationCode":"// C#\nif (width <= 0 || height <= 0)\n    throw new ArgumentOutOfRangeException(nameof(width), \"Video resolution must be positive\");\nvideoInstance.AllocateVideoTexture(width, height);","typeGuard":null,"tryCatchPattern":"// C#\ntry { videoInstance.AllocateVideoTexture(w, h); }\ncatch (InvalidOperationException ex) when (ex.Message == \"Invalid video resolution.\")\n{\n    videoInstance.AllocateVideoTexture(1280, 720); // safe fallback\n}","preventionTips":["Only allocate after the video metadata has been loaded and dimensions are known","Validate width/height > 0 before any texture allocation","Treat zero dimensions from video metadata as 'not loaded yet', not as real size"],"tags":["validation","video","texture","argument-out-of-range"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}