Skip to content

ZipArchive is not functioning in Blazor WebAssembly when using System.IO.Compression.ZipArchive and SkiaSharp v3.118.0-preview.1.2 in .NET 9.0. #3067

Closed
@pandi123

Description

@pandi123

Description

We are experiencing an issue with the System.IO.Compression.ZipArchive and SkiaSharp package v3.118.0-preview.1.2 in our Blazor WebAssembly .NET 9.0 project. The problem began after we added the following line in our .csproj file:
image

This issue does not occur when using the SkiaSharp package v2.88.8 or checking .NET 8.0 working fine. I have attached a sample project and a screenshot of the issue for your reference.

Platform: Blazor wasm
Visual Studio version: 2022
.NET version : .NET9
SkiaSharp version : v3.118.0-preview.1.2

Code

@page "/"
@using System.IO.Compression;
@using System.Xml.Linq;
@inject IJSRuntime JS;


<button @onclick="ZipArchive">Download ZIP</button>


@code {
    public async void ZipArchive()
    {
        using (MemoryStream zipStream = new MemoryStream())
        {
            using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
            {
                ZipArchiveEntry entry = archive.CreateEntry("Sample.xml");
                using (Stream entryStream = entry.Open())
                {
                    XDocument xmlDocument = new XDocument(
                        new XElement("Root",
                            new XElement("Child", "Content")
                        )
                    );
                    xmlDocument.Save(entryStream);
                }
            }
            zipStream.Position = 0;
            await JS.InvokeVoidAsync("downloadFileFromByteArray", "SampleArchive.zip", zipStream.ToArray());
        }
    }
}

Expected Behavior

The program should run without any exceptions in blazor wasm while using System.IO.Compression.ZipArchive and SkiaSharp package v3.118.0-preview.1.2

Actual Behavior

Aborted(Assertion failed: native function stackRestore called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits))
The thread '.NET TP Worker' (33996) has exited with code 0 (0x0).
The thread '.NET TP Worker' (42984) has exited with code 0 (0x0).
Uncaught RuntimeError RuntimeError: unreachable
at $__trap (wasm/022f640e.wat:3678318:1)
at ___trap (localhost꞉7023/_framework/dotnet.native.krq9w4nbeb.js:11275:54)
at abort (localhost꞉7023/_framework/dotnet.native.krq9w4nbeb.js:775:5)
at assert (localhost꞉7023/_framework/dotnet.native.krq9w4nbeb.js:468:5)
at (localhost꞉7023/_framework/dotnet.native.krq9w4nbeb.js:808:5)
at (d:\Net9\ZipArchive3.118.0-preview.1.2\ZipArchive3.118.0-preview.1.2\wwwroot_framework\https:\raw.githubusercontent.com\dotnet\runtime\9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3\src\mono\browser\runtime\invoke-cs.ts:328:20)
at beginInvokeDotNetFromJS (localhost꞉7023/_framework/blazor.webassembly.js:1:43656)
at invokeDotNetMethodAsync (localhost꞉7023/_framework/blazor.webassembly.js:1:3978)
at invokeMethodAsync (localhost꞉7023/_framework/blazor.webassembly.js:1:5486)
at (localhost꞉7023/_framework/blazor.webassembly.js:1:13036)
at R (localhost꞉7023/_framework/blazor.webassembly.js:1:13214)
at (localhost꞉7023/_framework/blazor.webassembly.js:1:52854)
at invokeWhenHeapUnlocked (localhost꞉7023/_framework/blazor.webassembly.js:1:44875)
at (localhost꞉7023/_framework/blazor.webassembly.js:1:52817)
at R (localhost꞉7023/_framework/blazor.webassembly.js:1:52844)
at I (localhost꞉7023/_framework/blazor.webassembly.js:1:13005)
at dispatchGlobalEventToAllElements (localhost꞉7023/_framework/blazor.webassembly.js:1:15626)
at onGlobalEvent (localhost꞉7023/_framework/blazor.webassembly.js:1:14835)

Version of SkiaSharp

3.118.0-preview.1 (Next Preview)

Last Known Good Version of SkiaSharp

2.88.8 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Window11

Devices

Visual studio v2022

Issue reproducing sample

ZipArchive3.118.0-preview.1.2.zip

Working sample

ZipArchive 2.88.8.zip

Relevant Screenshots

No response

Relevant Log Output

image (5)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions