diff options
author | Teravus Ovares | 2009-01-21 11:16:33 +0000 |
---|---|---|
committer | Teravus Ovares | 2009-01-21 11:16:33 +0000 |
commit | 1a55dd11f1e0c17452c3264ff02496d8ced8a421 (patch) | |
tree | a358deb7a59b1a46075b1dc5adf7f359edb3151c /OpenSim/Region/Environment/Modules | |
parent | - remove extra "; in http_loginform.html.example; fix issue 3025 (diff) | |
download | opensim-SC-1a55dd11f1e0c17452c3264ff02496d8ced8a421.zip opensim-SC-1a55dd11f1e0c17452c3264ff02496d8ced8a421.tar.gz opensim-SC-1a55dd11f1e0c17452c3264ff02496d8ced8a421.tar.bz2 opensim-SC-1a55dd11f1e0c17452c3264ff02496d8ced8a421.tar.xz |
* 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)
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
5 files changed, 105 insertions, 36 deletions
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 | |||
49 | /// Cached Decoded Layers | 49 | /// Cached Decoded Layers |
50 | /// </summary> | 50 | /// </summary> |
51 | private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>(); | 51 | private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>(); |
52 | private bool OpenJpegFail = false; | ||
52 | 53 | ||
53 | /// <summary> | 54 | /// <summary> |
54 | /// List of client methods to notify of results of decode | 55 | /// List of client methods to notify of results of decode |
@@ -147,49 +148,64 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
147 | int DecodeTime = 0; | 148 | int DecodeTime = 0; |
148 | DecodeTime = System.Environment.TickCount; | 149 | DecodeTime = System.Environment.TickCount; |
149 | OpenJPEG.J2KLayerInfo[] layers = new OpenJPEG.J2KLayerInfo[0]; // Dummy result for if it fails. Informs that there's only full quality | 150 | OpenJPEG.J2KLayerInfo[] layers = new OpenJPEG.J2KLayerInfo[0]; // Dummy result for if it fails. Informs that there's only full quality |
150 | try | ||
151 | { | ||
152 | 151 | ||
153 | AssetTexture texture = new AssetTexture(AssetId, j2kdata); | 152 | if (!OpenJpegFail) |
154 | if (texture.DecodeLayerBoundaries()) | 153 | { |
154 | try | ||
155 | { | 155 | { |
156 | bool sane = true; | ||
157 | 156 | ||
158 | // Sanity check all of the layers | 157 | AssetTexture texture = new AssetTexture(AssetId, j2kdata); |
159 | for (int i = 0; i < texture.LayerInfo.Length; i++) | 158 | if (texture.DecodeLayerBoundaries()) |
160 | { | 159 | { |
161 | if (texture.LayerInfo[i].End > texture.AssetData.Length) | 160 | bool sane = true; |
161 | |||
162 | // Sanity check all of the layers | ||
163 | for (int i = 0; i < texture.LayerInfo.Length; i++) | ||
162 | { | 164 | { |
163 | sane = false; | 165 | if (texture.LayerInfo[i].End > texture.AssetData.Length) |
164 | break; | 166 | { |
167 | sane = false; | ||
168 | break; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | if (sane) | ||
173 | { | ||
174 | layers = texture.LayerInfo; | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | m_log.WarnFormat( | ||
179 | "[J2KDecoderModule]: JPEG2000 texture decoding succeeded, but sanity check failed for {0}", | ||
180 | AssetId); | ||
165 | } | 181 | } |
166 | } | 182 | } |
167 | 183 | ||
168 | if (sane) | ||
169 | { | ||
170 | layers = texture.LayerInfo; | ||
171 | } | ||
172 | else | 184 | else |
173 | { | 185 | { |
174 | m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding succeeded, but sanity check failed for {0}", | 186 | m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}", AssetId); |
175 | AssetId); | ||
176 | } | 187 | } |
188 | texture = null; // dereference and dispose of ManagedImage | ||
189 | } | ||
190 | catch (DllNotFoundException) | ||
191 | { | ||
192 | m_log.Error( | ||
193 | "[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!"); | ||
194 | OpenJpegFail = true; | ||
195 | } | ||
196 | catch (Exception ex) | ||
197 | { | ||
198 | m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding threw an exception for {0}, {1}", | ||
199 | AssetId, ex); | ||
177 | } | 200 | } |
178 | |||
179 | else | ||
180 | { | ||
181 | m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}", AssetId); | ||
182 | } | ||
183 | texture = null; // dereference and dispose of ManagedImage | ||
184 | } | 201 | } |
185 | catch (Exception ex) | 202 | |
203 | if (!OpenJpegFail) | ||
186 | { | 204 | { |
187 | m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding threw an exception for {0}, {1}", AssetId, ex); | 205 | // Write out decode time |
206 | m_log.InfoFormat("[J2KDecoderModule]: {0} Decode Time: {1}", System.Environment.TickCount - DecodeTime, | ||
207 | AssetId); | ||
188 | } | 208 | } |
189 | |||
190 | // Write out decode time | ||
191 | m_log.InfoFormat("[J2KDecoderModule]: {0} Decode Time: {1}", System.Environment.TickCount - DecodeTime, AssetId); | ||
192 | |||
193 | // Cache Decoded layers | 209 | // Cache Decoded layers |
194 | lock (m_cacheddecode) | 210 | lock (m_cacheddecode) |
195 | { | 211 | { |
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 | |||
275 | 275 | ||
276 | Bitmap joint = MergeBitMaps(image1, image2); | 276 | Bitmap joint = MergeBitMaps(image1, image2); |
277 | 277 | ||
278 | return OpenJPEG.EncodeFromImage(joint, true); | 278 | byte[] result = new byte[0]; |
279 | |||
280 | try | ||
281 | { | ||
282 | result = OpenJPEG.EncodeFromImage(joint, true); | ||
283 | } | ||
284 | catch (Exception) | ||
285 | { | ||
286 | Console.WriteLine( | ||
287 | "[DYNAMICTEXTUREMODULE]: OpenJpeg Encode Failed. Empty byte data returned!"); | ||
288 | } | ||
289 | |||
290 | return result; | ||
279 | } | 291 | } |
280 | } | 292 | } |
281 | 293 | ||
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 | |||
168 | } | 168 | } |
169 | 169 | ||
170 | Bitmap resize = new Bitmap(image, newsize); | 170 | Bitmap resize = new Bitmap(image, newsize); |
171 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | 171 | byte[] imageJ2000 = new byte[0]; |
172 | |||
173 | try | ||
174 | { | ||
175 | imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | ||
176 | } | ||
177 | catch (Exception) | ||
178 | { | ||
179 | Console.WriteLine( | ||
180 | "[LOADIMAGEURLMODULE]: OpenJpeg Encode Failed. Empty byte data returned!"); | ||
181 | } | ||
172 | 182 | ||
173 | m_textureManager.ReturnData(state.RequestID, imageJ2000); | 183 | m_textureManager.ReturnData(state.RequestID, imageJ2000); |
174 | } | 184 | } |
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 | |||
169 | 169 | ||
170 | GDIDraw(data, graph); | 170 | GDIDraw(data, graph); |
171 | 171 | ||
172 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); | 172 | byte[] imageJ2000 = new byte[0]; |
173 | |||
174 | try | ||
175 | { | ||
176 | imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); | ||
177 | } | ||
178 | catch (Exception) | ||
179 | { | ||
180 | Console.WriteLine( | ||
181 | "[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Empty byte data returned!"); | ||
182 | } | ||
173 | m_textureManager.ReturnData(id, imageJ2000); | 183 | m_textureManager.ReturnData(id, imageJ2000); |
174 | } | 184 | } |
175 | 185 | ||
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 | |||
170 | 170 | ||
171 | ManagedImage managedImage; | 171 | ManagedImage managedImage; |
172 | Image image; | 172 | Image image; |
173 | if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image)) | 173 | |
174 | return new Bitmap(image); | 174 | try |
175 | else | 175 | { |
176 | return null; | 176 | if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image)) |
177 | return new Bitmap(image); | ||
178 | else | ||
179 | return null; | ||
180 | } | ||
181 | catch (DllNotFoundException) | ||
182 | { | ||
183 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", id); | ||
184 | |||
185 | } | ||
186 | catch (IndexOutOfRangeException) | ||
187 | { | ||
188 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); | ||
189 | |||
190 | } | ||
191 | catch (Exception) | ||
192 | { | ||
193 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); | ||
194 | |||
195 | } | ||
196 | return null; | ||
197 | |||
177 | } | 198 | } |
178 | 199 | ||
179 | // Compute the average color of a texture. | 200 | // Compute the average color of a texture. |