* More friendly OpenJpeg error handling.

* Often times now the only reason OpenJpeg doesn't work is because it requires Glibc 2.4    The error messages reflect that.
* In J2kDecoder module, It stops trying to decode modules if it encounters a dllnotfound exception and instead sends a full resolution layer that causes the texture sender to only send the full resolution image.  (big decrease in texture download speed, but it's better then nasty repeating error messages)
0.6.3-post-fixes
Teravus Ovares 2009-01-21 11:16:33 +00:00
parent 0e7aac0f65
commit 1a55dd11f1
7 changed files with 136 additions and 38 deletions

View File

@ -2136,7 +2136,25 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Stream tgadata = new MemoryStream(ic.Asset.Data);
temp = LoadTGAClass.LoadTGA(tgadata);
ic.Asset.Data = OpenJPEG.EncodeFromImage(temp, true);
try
{
ic.Asset.Data = OpenJPEG.EncodeFromImage(temp, true);
}
catch (DllNotFoundException)
{
Rest.Log.ErrorFormat("OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", ic.Item.Name);
ic.Asset.Data = new Byte[0];
}
catch (IndexOutOfRangeException)
{
Rest.Log.ErrorFormat("OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", ic.Item.Name);
ic.Asset.Data = new Byte[0];
}
catch (Exception)
{
Rest.Log.ErrorFormat("OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", ic.Item.Name);
ic.Asset.Data = new Byte[0];
}
}
ic.reset();

View File

@ -49,6 +49,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
/// Cached Decoded Layers
/// </summary>
private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>();
private bool OpenJpegFail = false;
/// <summary>
/// List of client methods to notify of results of decode
@ -147,49 +148,64 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
int DecodeTime = 0;
DecodeTime = System.Environment.TickCount;
OpenJPEG.J2KLayerInfo[] layers = new OpenJPEG.J2KLayerInfo[0]; // Dummy result for if it fails. Informs that there's only full quality
try
if (!OpenJpegFail)
{
AssetTexture texture = new AssetTexture(AssetId, j2kdata);
if (texture.DecodeLayerBoundaries())
try
{
bool sane = true;
// Sanity check all of the layers
for (int i = 0; i < texture.LayerInfo.Length; i++)
AssetTexture texture = new AssetTexture(AssetId, j2kdata);
if (texture.DecodeLayerBoundaries())
{
if (texture.LayerInfo[i].End > texture.AssetData.Length)
bool sane = true;
// Sanity check all of the layers
for (int i = 0; i < texture.LayerInfo.Length; i++)
{
sane = false;
break;
if (texture.LayerInfo[i].End > texture.AssetData.Length)
{
sane = false;
break;
}
}
if (sane)
{
layers = texture.LayerInfo;
}
else
{
m_log.WarnFormat(
"[J2KDecoderModule]: JPEG2000 texture decoding succeeded, but sanity check failed for {0}",
AssetId);
}
}
if (sane)
{
layers = texture.LayerInfo;
}
else
{
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding succeeded, but sanity check failed for {0}",
AssetId);
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}", AssetId);
}
texture = null; // dereference and dispose of ManagedImage
}
catch (DllNotFoundException)
{
m_log.Error(
"[J2KDecoderModule]: OpenJpeg is not installed properly. Decoding disabled! This will slow down texture performance! Often times this is because of an old version of GLIBC. You must have version 2.4 or above!");
OpenJpegFail = true;
}
catch (Exception ex)
{
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding threw an exception for {0}, {1}",
AssetId, ex);
}
else
{
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}", AssetId);
}
texture = null; // dereference and dispose of ManagedImage
}
catch (Exception ex)
{
m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding threw an exception for {0}, {1}", AssetId, ex);
}
// Write out decode time
m_log.InfoFormat("[J2KDecoderModule]: {0} Decode Time: {1}", System.Environment.TickCount - DecodeTime, AssetId);
if (!OpenJpegFail)
{
// Write out decode time
m_log.InfoFormat("[J2KDecoderModule]: {0} Decode Time: {1}", System.Environment.TickCount - DecodeTime,
AssetId);
}
// Cache Decoded layers
lock (m_cacheddecode)
{

View File

@ -275,7 +275,19 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
Bitmap joint = MergeBitMaps(image1, image2);
return OpenJPEG.EncodeFromImage(joint, true);
byte[] result = new byte[0];
try
{
result = OpenJPEG.EncodeFromImage(joint, true);
}
catch (Exception)
{
Console.WriteLine(
"[DYNAMICTEXTUREMODULE]: OpenJpeg Encode Failed. Empty byte data returned!");
}
return result;
}
}

View File

@ -168,7 +168,17 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
}
Bitmap resize = new Bitmap(image, newsize);
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
byte[] imageJ2000 = new byte[0];
try
{
imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
}
catch (Exception)
{
Console.WriteLine(
"[LOADIMAGEURLMODULE]: OpenJpeg Encode Failed. Empty byte data returned!");
}
m_textureManager.ReturnData(state.RequestID, imageJ2000);
}

View File

@ -169,7 +169,17 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
GDIDraw(data, graph);
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true);
byte[] imageJ2000 = new byte[0];
try
{
imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true);
}
catch (Exception)
{
Console.WriteLine(
"[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Empty byte data returned!");
}
m_textureManager.ReturnData(id, imageJ2000);
}

View File

@ -170,10 +170,31 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
ManagedImage managedImage;
Image image;
if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
return new Bitmap(image);
else
return null;
try
{
if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
return new Bitmap(image);
else
return null;
}
catch (DllNotFoundException)
{
m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", id);
}
catch (IndexOutOfRangeException)
{
m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id);
}
catch (Exception)
{
m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id);
}
return null;
}
// Compute the average color of a texture.

View File

@ -181,6 +181,17 @@ namespace OpenSim.Region.Physics.Meshing
{
ManagedImage managedImage; // we never use this
OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
}
catch (DllNotFoundException)
{
System.Console.WriteLine("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!");
return null;
}
catch (IndexOutOfRangeException)
{
System.Console.WriteLine("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
return null;
}
catch (Exception)
{