From 1a55dd11f1e0c17452c3264ff02496d8ced8a421 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 21 Jan 2009 11:16:33 +0000 Subject: * 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) --- .../Rest/Inventory/RestInventoryServices.cs | 20 +++++- .../Agent/TextureSender/J2KDecoderModule.cs | 74 +++++++++++++--------- .../DynamicTexture/DynamicTextureModule.cs | 14 +++- .../Scripting/LoadImageURL/LoadImageURLModule.cs | 12 +++- .../Scripting/VectorRender/VectorRenderModule.cs | 12 +++- .../World/WorldMap/TexturedMapTileRenderer.cs | 29 +++++++-- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 11 ++++ 7 files changed, 135 insertions(+), 37 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index 913eb0c..2dce706 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs @@ -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(); diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs index 6b84880..dc46dc6 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs @@ -49,6 +49,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender /// Cached Decoded Layers /// private readonly Dictionary m_cacheddecode = new Dictionary(); + private bool OpenJpegFail = false; /// /// 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 - { - AssetTexture texture = new AssetTexture(AssetId, j2kdata); - if (texture.DecodeLayerBoundaries()) + if (!OpenJpegFail) + { + 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) + + if (!OpenJpegFail) { - 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); } - - // Write out decode time - m_log.InfoFormat("[J2KDecoderModule]: {0} Decode Time: {1}", System.Environment.TickCount - DecodeTime, AssetId); - // Cache Decoded layers lock (m_cacheddecode) { diff --git a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs index 59d29d6..e9fe373 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -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; } } diff --git a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs index 631051b..eeeb3ca 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs @@ -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); } diff --git a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs index f8a9879..ffbc262 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs @@ -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); } diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs index c5efb4f..d66bbdb 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs @@ -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. diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 92aae1a..72575e5 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -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) { -- cgit v1.1