public static void Dump(AssetLibrary_Texture library, Dictionary <string, RefCountedTextureData> textureData, CrashPayload payload) { var apkData = library.masterAssets .Select(x => new TextureInfo() { id = x.Key.ToString(), width = x.Value.asset.texture.width, height = x.Value.asset.texture.height, mipmaps = x.Value.asset.texture.mipmapCount, format = x.Value.asset.texture.graphicsFormat.ToString(), refCount = x.Value.referenceCount }); var persistentCacheData = textureData .Select(x => new TextureInfo() { id = x.Key, height = x.Value.Texture.width, mipmaps = x.Value.Texture.mipmapCount, format = x.Value.Texture.graphicsFormat.ToString(), refCount = x.Value.RefCount }); TextureInfo[] finalData = apkData.Union(persistentCacheData).ToArray(); payload.fields.Add(CrashPayload.DumpLiterals.TEXTURES, finalData); }
public static void Dump(Dictionary <string, IParcelScene> allScenes, AssetLibrary_Texture library, Dictionary <string, RefCountedTextureData> textureData, CrashPayload payload) { var componentsDump = new List <ComponentsDump>(); var totalSceneLimits = new WebInterface.MetricsModel(); var loadedScenes = allScenes .Select(x => new LoadedScenesDump { id = x.Key } ) .ToList(); // <class, count> Dictionary <int, int> sharedComponentsCount = new Dictionary <int, int>(); Dictionary <int, int> entityComponentsCount = new Dictionary <int, int>(); foreach (var kvp in allScenes) { IParcelScene scene = kvp.Value; // Sum operator is overloaded totalSceneLimits += scene.metricsController.GetModel().ToMetricsModel(); loadedScenes.Add(new LoadedScenesDump { id = kvp.Key } ); foreach (var kvpComponents in scene.disposableComponents) { int classId = kvpComponents.Value.GetClassId(); if (!sharedComponentsCount.ContainsKey(classId)) { sharedComponentsCount.Add(classId, 0); } sharedComponentsCount[classId]++; } foreach (var kvpEntities in kvp.Value.entities) { foreach (var kvpComponents in kvpEntities.Value.components) { int classId = kvpComponents.Value.GetClassId(); if (!entityComponentsCount.ContainsKey(classId)) { entityComponentsCount.Add(classId, 0); } entityComponentsCount[classId]++; } } } foreach (var kvp in sharedComponentsCount) { componentsDump.Add(new ComponentsDump { type = ((CLASS_ID)kvp.Key).ToString(), quantity = kvp.Value } ); } foreach (var kvp in entityComponentsCount) { componentsDump.Add(new ComponentsDump { type = ((CLASS_ID_COMPONENT)kvp.Key).ToString(), quantity = kvp.Value } ); } // Materials and textures can be shared between scenes. They can't be inferred by adding up the metrics. totalSceneLimits.materials = PersistentAssetCache.MaterialCacheByCRC.Count; totalSceneLimits.textures = library.masterAssets.Count + textureData.Count; payload.fields.Add(CrashPayload.DumpLiterals.COMPONENTS, componentsDump.ToArray()); payload.fields.Add(CrashPayload.DumpLiterals.LOADED_SCENES, loadedScenes.ToArray()); payload.fields.Add(CrashPayload.DumpLiterals.TOTAL_SCENE_LIMITS, totalSceneLimits); }