From 0b91ec8dd2b78461cb0fcdec567a83e88a76ac87 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 19 Dec 2011 18:58:05 +0000 Subject: [PATCH] Migrate detailed "appearance show" report generation up to AvatarFactoryModule from AppearanceInfoModule so that it can be used in debug (inactive). Further filters "debug packet " to exclused [Request]ObjectPropertiesFamily if level is below 25. Adjust some method doc Minor changes to some logging messages. --- .../UploadBakedTextureHandler.cs | 4 +- OpenSim/Framework/AvatarAppearance.cs | 21 ++++--- .../ClientStack/Linden/UDP/LLClientView.cs | 17 ++++-- .../AvatarFactory/AvatarFactoryModule.cs | 57 ++++++++++++++++--- .../Interfaces/IAvatarFactoryModule.cs | 11 +++- .../Region/Framework/Scenes/ScenePresence.cs | 2 +- .../Avatar/Appearance/AppearanceInfoModule.cs | 34 +---------- 7 files changed, 90 insertions(+), 56 deletions(-) diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs index c637ccf180..594ce9dad9 100644 --- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs @@ -104,7 +104,7 @@ namespace OpenSim.Capabilities.Handlers } catch (Exception e) { - m_log.Error("[UPLOAD BAKED TEXTURE HANDLER]: " + e.ToString()); + m_log.ErrorFormat("[UPLOAD BAKED TEXTURE HANDLER]: {0}{1}", e.Message, e.StackTrace); } return null; @@ -117,7 +117,7 @@ namespace OpenSim.Capabilities.Handlers /// private void BakedTextureUploaded(UUID assetID, byte[] data) { - // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); +// m_log.DebugFormat("[UPLOAD BAKED TEXTURE HANDLER]: Received baked texture {0}", assetID.ToString()); AssetBase asset; asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString()); diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 6c2a954f07..4f598b04ae 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -249,10 +249,12 @@ namespace OpenSim.Framework } /// - /// Set up appearance textures. - /// Returns boolean that indicates whether the new entries actually change the - /// existing values. + /// Set up appearance texture ids. /// + /// + /// True if any existing texture id was changed by the new data. + /// False if there were no changes or no existing texture ids. + /// public virtual bool SetTextureEntries(Primitive.TextureEntry textureEntry) { if (textureEntry == null) @@ -269,25 +271,30 @@ namespace OpenSim.Framework if (newface == null) { - if (oldface == null) continue; + if (oldface == null) + continue; } else { - if (oldface != null && oldface.TextureID == newface.TextureID) continue; + if (oldface != null && oldface.TextureID == newface.TextureID) + continue; } changed = true; } m_texture = textureEntry; + return changed; } /// /// Set up visual parameters for the avatar and refresh the avatar height - /// Returns boolean that indicates whether the new entries actually change the - /// existing values. /// + /// + /// True if any existing visual parameter was changed by the new data. + /// False if there were no changes or no existing visual parameters. + /// public virtual bool SetVisualParams(byte[] visualParams) { if (visualParams == null) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 8b41c493da..f9a6643063 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -441,6 +441,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public LLClientView(EndPoint remoteEP, Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo, UUID agentId, UUID sessionId, uint circuitCode) { +// DebugPacketLevel = 1; + RegisterInterface(this); RegisterInterface(this); RegisterInterface(this); @@ -6001,7 +6003,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP // for the client session anyway, in order to protect ourselves against bad code in plugins try { - byte[] visualparams = new byte[appear.VisualParam.Length]; for (int i = 0; i < appear.VisualParam.Length; i++) visualparams[i] = appear.VisualParam[i].ParamValue; @@ -11219,9 +11220,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Send a response back to a client when it asks the asset server (via the region server) if it has /// its appearance texture cached. - /// - /// At the moment, we always reply that there is no cached texture. /// + /// + /// At the moment, we always reply that there is no cached texture. + /// /// /// /// @@ -11231,7 +11233,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse); - if (cachedtex.AgentData.SessionID != SessionId) return false; + if (cachedtex.AgentData.SessionID != SessionId) + return false; // TODO: don't create new blocks if recycling an old packet cachedresp.AgentData.AgentID = AgentId; @@ -11629,6 +11632,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (DebugPacketLevel <= 50 && packet.Type == PacketType.ImprovedTerseObjectUpdate) logPacket = false; + if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily) + logPacket = false; + if (logPacket) m_log.DebugFormat( "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}", @@ -11686,6 +11692,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation)) logPacket = false; + if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily) + logPacket = false; + if (logPacket) m_log.DebugFormat( "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}", diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 29e35800a0..f1a81aecd3 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -26,16 +26,15 @@ */ using System; +using System.Collections.Generic; using System.Reflection; +using System.Threading; +using System.Text; +using System.Timers; using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; - -using System.Threading; -using System.Timers; -using System.Collections.Generic; - using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; @@ -45,6 +44,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public class AvatarFactoryModule : IAvatarFactoryModule, IRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public const string BAKED_TEXTURES_REPORT_FORMAT = "{0,-9} {1}"; + private Scene m_scene = null; private int m_savetime = 5; // seconds to wait before saving changed appearance @@ -147,9 +149,13 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // Process the baked texture array if (textureEntry != null) { + m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID); + +// WriteBakedTexturesReport(sp, m_log.DebugFormat); + changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; - m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID); +// WriteBakedTexturesReport(sp, m_log.DebugFormat); ValidateBakedTextureCache(sp, false); // This appears to be set only in the final stage of the appearance @@ -254,9 +260,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } /// - /// Queue up a request to send appearance, makes it possible to - /// accumulate changes without sending out each one separately. + /// Queue up a request to send appearance. /// + /// + /// Makes it possible to accumulate changes without sending out each one separately. + /// + /// public void QueueAppearanceSend(UUID agentid) { // m_log.DebugFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); @@ -557,5 +566,37 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } } #endregion + + public void WriteBakedTexturesReport(IScenePresence sp, ReportOutputAction outputAction) + { + outputAction("For {0} in {1}", sp.Name, m_scene.RegionInfo.RegionName); + outputAction(BAKED_TEXTURES_REPORT_FORMAT, "Bake Type", "UUID"); + + Dictionary bakedTextures = GetBakedTextureFaces(sp.UUID); + + foreach (BakeType bt in bakedTextures.Keys) + { + string rawTextureID; + + if (bakedTextures[bt] == null) + { + rawTextureID = "not set"; + } + else + { + rawTextureID = bakedTextures[bt].TextureID.ToString(); + + if (m_scene.AssetService.Get(rawTextureID) == null) + rawTextureID += " (not found)"; + else + rawTextureID += " (uploaded)"; + } + + outputAction(BAKED_TEXTURES_REPORT_FORMAT, bt, rawTextureID); + } + + bool bakedTextureValid = m_scene.AvatarFactory.ValidateBakedTextureCache(sp); + outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); + } } } diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs index 26bc922748..8670229e8b 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs @@ -31,9 +31,10 @@ using OpenSim.Framework; namespace OpenSim.Region.Framework.Interfaces { + public delegate void ReportOutputAction(string format, params object[] args); + public interface IAvatarFactoryModule { - void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams); /// @@ -63,5 +64,13 @@ namespace OpenSim.Region.Framework.Interfaces bool ValidateBakedTextureCache(IScenePresence sp); void QueueAppearanceSend(UUID agentid); void QueueAppearanceSave(UUID agentid); + + /// + /// Get a report about the current state of a scene presence's baked appearance textures. + /// + /// + /// + /// + void WriteBakedTexturesReport(IScenePresence sp, ReportOutputAction reportOutputAction); } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7be95cd9d1..f2e2ce719a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2667,7 +2667,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAppearanceToAgent(ScenePresence avatar) { // m_log.DebugFormat( -// "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); +// "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); avatar.ControllingClient.SendAppearance( UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 40cbc606a1..1ce24f1745 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -50,8 +50,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public const string SHOW_APPEARANCE_FORMAT = "{0,-9} {1}"; - private Dictionary m_scenes = new Dictionary(); // private IAvatarFactoryModule m_avatarFactory; @@ -197,37 +195,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance { ScenePresence sp = scene.GetScenePresence(optionalTargetFirstName, optionalTargetLastName); if (sp != null && !sp.IsChildAgent) - { - MainConsole.Instance.OutputFormat("For {0} in {1}", sp.Name, scene.RegionInfo.RegionName); - MainConsole.Instance.OutputFormat(SHOW_APPEARANCE_FORMAT, "Bake Type", "UUID"); - - Dictionary bakedTextures - = scene.AvatarFactory.GetBakedTextureFaces(sp.UUID); - foreach (BakeType bt in bakedTextures.Keys) - { - string rawTextureID; - - if (bakedTextures[bt] == null) - { - rawTextureID = "not set"; - } - else - { - rawTextureID = bakedTextures[bt].TextureID.ToString(); - - if (scene.AssetService.Get(rawTextureID) == null) - rawTextureID += " (not found)"; - else - rawTextureID += " (uploaded)"; - } - - MainConsole.Instance.OutputFormat(SHOW_APPEARANCE_FORMAT, bt, rawTextureID); - } - - bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); - MainConsole.Instance.OutputFormat( - "{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); - } + scene.AvatarFactory.WriteBakedTexturesReport(sp, MainConsole.Instance.OutputFormat); } else {