Announcements
The Scaleform forum is now read-only. Please head to the Gamedev site for product support.

Wrong JPEG library version issue on iOS built from Unity w. Scaleform.

Wrong JPEG library version issue on iOS built from Unity w. Scaleform.

Anonymous
Not applicable
3,571 Views
10 Replies
Message 1 of 11

Wrong JPEG library version issue on iOS built from Unity w. Scaleform.

Anonymous
Not applicable

Hi there.

 

Our iOS game loads in textures from the internet using Unity's WWW class. When including Scaleform into the project, we encounter a runtime iOS library issue when attempting to assign a Texture2D instance to the texture returned from a WWW call.  

 

To show you a code snippet: The following works on iOS and Mac WITHOUT Scaleform included in the Unity project. With Scaleform included it ONLY works on Mac, but on iOS it fails to load in the texture using either of the below methods.  Looking forward to any insights here. 🙂

 

Texture2D wwwTexture = new Texture2D(256, 256,TextureFormat.ARGB32,false);

using (WWW w = new WWW(getURL())) {
yield return w;

if (w != null && w.isDone && w.error == null)
{

//method 1..
wwwTexture = w.texture; // !! causing xCode error 'Wrong JPEG library version: library is 80, caller expects 61'

 

//method 2..

w.LoadImageIntoTexture(wwwTexture); //// !! causing xCode error 'Wrong JPEG library version: library is 80, caller expects 61'


}
}

 

 

Reply
Reply
0 Likes
Accepted solutions (1)
3,572 Views
10 Replies
Replies (10)
Message 2 of 11

AD_ADeCastro
Alumni
Alumni

Hello,

 

Can you please send me a reproduction case? We can't really tell what's wrong only by that snippet of code.

 

Thank you!

 

Best regards,

Angela

Reply
Reply
0 Likes
Message 3 of 11

Anonymous
Not applicable

I'm having the same issue, it's really simple to reproduce it as well.


NOTE: It only occurs when building to an iOS device, this error message DOES NOT pop up when using the Editor!

 

The version of libjpeg included in Unity's libiPhone-lib.a file is an older version than what was included in Scaleform 4.2's libraries (which are copied over using the PostprocessBuildPlayer perl script)

 

Scaleform copies libjpeg.a from the Unity Project Root/Assets/Lib/iPhone-armv7/clang/libjpeg.a when deploying to the Xcode project created when you do a build inside Unity for iOS

 

Here's the steps to reproduce this issue:

1) Create a new Unity project

2) Import Scaleform's .unitypackage as per the readme/tutorial docs (NOTE: I also tested it with the ScaleformTutorial_Consumer.unitypackage as we have purchased a SF/Unity iOS license)

3) Create a folder called 'Resources' under the 'Assets' folder

4) Create a folder called 'Levels' under the 'Resources' folder

5) Place Level0001.jpeg in the 'Levels' folder (NOTE: It is not a jpeg, I had to rename it to upload to this forum)

6) Rename the Level0001.jpeg to Level0001.bytes

7) Create a script called TestJPEGLibrary.cs in the Assets/scripts folder

8) Paste the listing below (TestJPEGLibrary.cs) in the above script file

9) Open the main_level.unity scene from the demo you extracted

10) Create an empty GameObject and attach TestJPEGLibrary.cs to it

11) Build to an iOS Device (I selected the 'Symlink Unity libraries' checkbox)

 

 

NOTE: that the issue occurs when calling the Texture2D.LoadImage(byte [] data) method (I would assume the same would be true when using www.data as per Mann1ng's post.

 

The following is printed in the Xcode console when running the build with an attached device:

Wrong JPEG library version: library is 80, caller expects 61

 

Because of the version mismatch, any data loaded by the Texture2D is invalid/corrupt/useless.

 

Listing for TestJPEGLibrary.cs:

using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using System.IO;
#endif

public class TestJPEGLibrary : MonoBehaviour
{
	private bool hasTriedLevelLoad = false;

	public void Update()
	{
		if(!hasTriedLevelLoad)
		{
			hasTriedLevelLoad = true;
			LoadLevel("Level0001");
		}
	}

	public void LoadLevel(string name)
	{
		if (string.IsNullOrEmpty(name))
		{
			Debug.LogError("Invalid Level Name: Empty");
			return;
		}
		//UNITY DOES NOT RELOAD .bytes files in resources until Unity is reloaded or some other conditions are met
		//Building to device uses the resources loaded in memory and not the actual files in the folder
#if UNITY_EDITOR
		if (!File.Exists(Application.dataPath + "/Resources/Levels/" + name + ".bytes"))
		{
			Debug.LogError("Invalid Level Name: Does not exist");
			return;
		}
		byte [] bytes = File.ReadAllBytes(Application.dataPath + "/Resources/Levels/" + name + ".bytes");
#else
		TextAsset ta = Resources.Load("Levels/" + name) as TextAsset;
		if (ta == null)
		{
			Debug.LogError("Invalid Level Name: Does not exist");
			return;
		}
		byte[] bytes = ta.bytes;
#endif

		Texture2D level = new Texture2D(0, 0);
		level.LoadImage(bytes);

		MonoBehaviour.Destroy(level);
	}
}

 

Reply
Reply
0 Likes
Message 4 of 11

jpratliff
Alumni
Alumni
Accepted solution

Thanks for the repro case.  Please try the updated pacakge below:

 

https://autodesk1.box.com/s/hfpyysf18tuw49fsht82

 

We downgraded the versions of JPEG and PNG that we build against to match the versions that Unity uses.

Reply
Reply
Message 5 of 11

Anonymous
Not applicable

I've integrated the changes and the issue has been fixed, thank you!

Reply
Reply
0 Likes
Message 6 of 11

Anonymous
Not applicable

Really great - many thanks - this has worked. I'm crossing my fingers that Autodesk will be closely tracking all potential lib conflicts that would arise whenever Unity decide to use more up-to-date versions of libraries shared between scaleform and unity in future Unity releases. Thanks again.

Reply
Reply
0 Likes
Message 7 of 11

Anonymous
Not applicable

Hello,

I'm having the same issue here. But the package is not available for download anymore.

Could you share it again or indicate me where I could find it.

 

Thanks in advance.

 

 

Reply
Reply
0 Likes
Message 8 of 11

jpratliff
Alumni
Alumni

Sorry about that, here's the new link:

 

https://autodesk1.box.com/s/r6aa6bfuibmm7o7uqtt5

Reply
Reply
0 Likes
Message 9 of 11

Anonymous
Not applicable

it is happening again

 

scaleform version from july 2014, unity version: 4.5.2f1

 

please, can you send an updated libjpeg patch?

Reply
Reply
0 Likes
Message 10 of 11

Anonymous
Not applicable

I've found a quick fix for this problem is to add these 2 lines to the Scaleform PostprocessBuildPlayer Perl script after all the system("cp -rf  *****"); calls somewhere around line 169 or later to remove Scaleform's libjpeg and libpng libraries from the build;

 

    system("rm \"$installPath\"/Libraries/ScaleformLib/libjpeg.a");
    system("rm \"$installPath\"/Libraries/ScaleformLib/libpng.a");

 

Hope this helps people out!

Reply
Reply
0 Likes
Message 11 of 11

Anonymous
Not applicable

Guys, help me. No one of the options does not work. Plz.

Reply
Reply
0 Likes