unoplatform/uno · error · NotSupportedException
GenerateBitmap is not supported by this platform
Error message
GenerateBitmap is not supported by this platform
What it means
Thrown by SampleChooserViewModel.GenerateBitmap on the WebAssembly (__WASM__) build. RenderTargetBitmap rendering to a PNG file via BitmapEncoder is not available on WASM, so the method short-circuits with NotSupportedException. The method is compiled conditionally: on non-WASM it is async and performs the render; on WASM it throws immediately.
Source
Thrown at src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs:1301
var folder = await GetStorageFolderFromNameOrCreate(ct, folderName);
if (_log.IsEnabled(LogLevel.Debug))
{
_log.Debug($"Output folder for tests: {folder.Path}");
}
}
private
#if !__WASM__
async
#endif
Task GenerateBitmap(CancellationToken ct
, Microsoft.UI.Xaml.Media.Imaging.RenderTargetBitmap targetBitmap
, StorageFile file
, FrameworkElement content)
{
#if __WASM__
throw new NotSupportedException($"GenerateBitmap is not supported by this platform");
#else
var element = Owner.XamlRoot.Content;
try
{
targetBitmap = new Microsoft.UI.Xaml.Media.Imaging.RenderTargetBitmap();
await targetBitmap.RenderAsync(element).AsTask(ct);
var pixels = await targetBitmap.GetPixelsAsync().AsTask(ct);
using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite).AsTask(ct))
{
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream).AsTask(ct);
encoder.SetPixelData(
BitmapPixelFormat.Bgra8,
BitmapAlphaMode.Ignore,View on GitHub (pinned to 0418340488)
Solutions
- Skip the bitmap-generation step on WASM — guard the caller with '#if !__WASM__' or a runtime platform check before invoking GenerateBitmap.
- Run the screenshot flow on a non-WASM host (Skia desktop) where RenderTargetBitmap is supported.
- If WASM screenshots are required, use the WASM HTML-capture/screenshot tooling instead of RenderTargetBitmap.
Example fix
// before
#if __WASM__
throw new NotSupportedException($"GenerateBitmap is not supported by this platform");
#else
... render ...
#endif
// after - guard the caller so the method is never entered on WASM
#if !__WASM__
await GenerateBitmap(ct, targetBitmap, file, content);
#else
_log.Information("Skipping bitmap generation on WASM.");
#endif Defensive patterns
Strategy: validation
Validate before calling
#if !__WASM__
await GenerateBitmap(ct, targetBitmap, file, content);
#else
_log.Information("Bitmap generation skipped on WASM.");
#endif Try / catch
try { await GenerateBitmap(ct, targetBitmap, file, content); }
catch (NotSupportedException ex) when (ex.Message.Contains("GenerateBitmap is not supported"))
{ _log.Information(ex.Message); } Prevention
- Gate platform-unsupported features with compile-time or runtime platform checks at the call site.
- Run bitmap/screenshot flows on Skia desktop, not WASM.
- Document which features are unavailable per platform.
When it happens
Trigger: Running the sample-chooser screenshot/bitmap-generation flow under the WASM host. The build define __WASM__ routes execution to the throw branch.
Common situations: Test/CI harness targeting WASM that invokes screenshot generation; running the full SamplesApp on WASM where bitmap dumping is part of the test runner.
Related errors
- StepBackwardOneFrame is not supported
- StepForwardOneFrame is not supported
- retrieveFiles failed to find pending drag and drop data for
- Keyboard lock is not supported by this browser.
- BrowserHtmlElement: Element with id '${id}' not found.
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/790310a7f126fa38.
Report an issue: GitHub.