{"record":{"id":"3e5c83b29915a8e4","repo":"unoplatform/uno","slug":"setsurfacesize-is-not-supported","errorCode":null,"errorMessage":"SetSurfaceSize is not supported","messagePattern":"SetSurfaceSize is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs","lineNumber":473,"sourceCode":"\t\t\tif (this.Log().IsEnabled(LogLevel.Debug))\n\t\t\t{\n\t\t\t\tthis.Log().Debug($\"MediaPlayerExtension.Play(): Failed {ex}\");\n\t\t\t}\n\t\t\tOnMediaFailed(ex);\n\t\t}\n\t}\n\n\tpublic void SetFileSource(IStorageFile file)\n\t\t=> throw new NotSupportedException($\"IStorageFile is not supported\");\n\n\tpublic void SetMediaSource(IMediaSource source)\n\t\t=> throw new NotSupportedException($\"IMediaSource is not supported\");\n\n\tpublic void SetStreamSource(IRandomAccessStream stream)\n\t\t=> throw new NotSupportedException($\"IRandomAccessStream is not supported\");\n\n\tpublic void SetSurfaceSize(Size size)\n\t\t=> throw new NotSupportedException($\"SetSurfaceSize is not supported\");\n\n\tpublic void SetUriSource(Uri uri)\n\t{\n\t\tif (this.Log().IsEnabled(LogLevel.Debug))\n\t\t{\n\t\t\tthis.Log().Debug($\"MediaPlayerExtension.SetUriSource({uri})\");\n\t\t}\n\n\t\tif (_player is not null)\n\t\t{\n\t\t\t_player.Source = uri.OriginalString;\n\t\t}\n\t}\n\n\tpublic void StepBackwardOneFrame()\n\t\t=> throw new NotSupportedException($\"StepBackwardOneFrame is not supported\");\n\n\tpublic void StepForwardOneFrame()","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs#L455-L491","documentation":"NotSupportedException thrown by MediaPlayerExtension.SetSurfaceSize on WebAssembly. The WASM media extension does not support explicit surface-size control (the HTML <video> element sizes via layout); calling SetSurfaceSize always throws.","triggerScenarios":"Calling SetSurfaceSize(Size) on the WASM media extension from shared code that configures a fixed rendering surface size.","commonSituations":"Cross-platform code that sets a surface size for native video rendering; porting desktop behavior to WASM where size is driven by CSS/layout.","solutions":["On WASM, control size via the MediaPlayerElement's layout/CSS rather than SetSurfaceSize.","Branch by platform: skip SetSurfaceSize on WASM.","Guard the call site with OperatingSystem.IsBrowser().","If a fixed size is required, set Width/Height on the hosting element instead."],"exampleFix":"// before — shared size configuration\nextension.SetSurfaceSize(new Size(640, 360));\n\n// after — skip on WASM, size via layout\n#if !__WASM__\n    extension.SetSurfaceSize(new Size(640, 360));\n#else\n    mediaPlayerElement.Width = 640; mediaPlayerElement.Height = 360;\n#endif","handlingStrategy":"validation","validationCode":"// Do not call SetSurfaceSize on WASM; size via layout\nif (!OperatingSystem.IsBrowser())\n    extension.SetSurfaceSize(size);\nelse\n    mediaPlayerElement.Width = size.Width;","typeGuard":"bool SupportsSetSurfaceSize() => !OperatingSystem.IsBrowser();","tryCatchPattern":"try { extension.SetSurfaceSize(size); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"SetSurfaceSize\"))\n{ Log.Error(\"SetSurfaceSize unsupported on WASM — size via layout\"); }","preventionTips":["Control WASM video size via the element's layout/CSS, not SetSurfaceSize.","Guard SetSurfaceSize with a platform check.","Set Width/Height on the hosting element instead."],"tags":["media-player","wasm","surface","unsupported","uno-platform"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}