MiloszKrajewski / K4os.Compression.LZ4

LZ4/LH4HC compression for .NET Standard 1.6/2.0 (formerly known as lz4net)
MIT License
675 stars 77 forks source link

LZ4 with Maui #89

Open Yannikk1996 opened 1 year ago

Yannikk1996 commented 1 year ago

Description When try to compress on a Maui Project. The function crashs on Android and iOS. Maui Windows works fine.

To reproduce Compress on any Maui Android/iOS project: K4os.Compression.LZ4.LZ4Codec.Encode(data, dest, K4os.Compression.LZ4.LZ4Level.L12_MAX);

Expected behavior Compress Data

Actual behavior Compress function crashes with in LL64.high.cs on line 107 at Assert(matchIndex < ipIndex);

Environment

MiloszKrajewski commented 1 year ago

Start here: https://github.com/MiloszKrajewski/K4os.Compression.LZ4#armv7-il2cpp-unity

Yannikk1996 commented 1 year ago

Thanks for your fast response. I also tried to use LZ4Codec.Enforce32 = true; but then it will crash in LL32.high.cs on line 114 with the same error. Xamarin worked fine.

MiloszKrajewski commented 1 year ago

"Xamarin"? What do you mean? Running same thing on "Mono"? Or Xamarin.Forms vs MaUI? Can you provide me data which causes the problem?

Yannikk1996 commented 1 year ago

Sorry to not be clear. Compressing using your LZ4 Library on Xamarin.Forms worked fine with Android / iOS. On Maui the compress function crashes by compressing data blocks with Android / iOS. It happens with any data block that can be compressed. But after a little bit of testing, it works when using LZ4Level.L00_FAST. It does not work with any other LZ4Level.

Yannikk1996 commented 1 year ago

Then it works with and without LZ4Codec.Enforce32 = true;

MiloszKrajewski commented 1 year ago

Hmmm, that's very intriguing. What is different when you run on Xamarin.Forms and on MaUI. Does it use different runtime? Does it use Mono or .NET 6? I assume same data work absolutely fine on Desktop (Windows or Linux but on Intel)?

Yannikk1996 commented 1 year ago

Xamarin Forms runs on .Net Standard 2.1 i think. Maui runs on Net 6/7. I think Mono is the underlying framework in both. It works absolutley fine on Maui Desktop Windows 32/64bit.