question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

String corruption with VipsForeignLoad / VipsForeignSave when using in Unity

See original GitHub issue

When trying to use NetVips in Unity (2020.3.12f1), we are seeing string corruption issues with methods that call VipsForeignLoad / VipsForeignSave:

For example:

public Image GetImage()
{
   return Image.NewFromFile("/Users/jmillard/Desktop/test.png");
}

errors with:

VipsException: unable to load from file /Users/jmillard/Desktop/test.png
VipsForeignLoad: file "/Users/jmillard/Desktop/test.png�Le�" does not exist

and

var path = texture.GetUnityFilename(folder);
Debug.Log($"Writing to {path}");
var im = texture.GetImage();
File.WriteAllBytes(path, im.WriteToBuffer(".png"));

errors with:

VipsException: unable to write to buffer
VipsForeignSave: ".pngallrolling3" is not a known buffer format

We are seeing this on MacOS and Windows. (Did not try on Linux yet)

Screen Shot 2021-06-19 at 5 12 30 PM

Screen Shot 2021-06-19 at 5 18 43 PM

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kleisaukecommented, Jun 23, 2021

NetVips v2.0.1 is now available. Thanks for reporting this!

2reactions
kleisaukecommented, Jun 20, 2021

Thanks for these instructions, I could reproduce it on Windows. It seems that the Mono version provided by Unity doesn’t properly null-terminate strings(?), I was able to fix/workaround this with commit https://github.com/kleisauke/net-vips/commit/95a9627d7d48c6fa1ab97f80748e54aa38710eab (which should be available as nightly version 2.0.0 build number 277).

I’ll investigate further why this only occurs on Mono and not on .NET Core/Framework, in the meantime you might also be interested in these changes: https://github.com/freezy/VisualPinball.Engine/compare/refactor/scene-netvips-test...kleisauke:refactor/scene-netvips-test

Read more comments on GitHub >

github_iconTop Results From Across the Web

Constant data corruption in Text Component (maybe more)
I'm using Layout Group components and these components keep making changes in the scene even I didn't touch at all, mostly floating point...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found