Skip to content

Commit f636b1f

Browse files
committed
testing some bug fixes
looking more into issues people cant be trusted implemented a adjuster
1 parent 2e7d23b commit f636b1f

35 files changed

Lines changed: 258 additions & 98 deletions

Basis Server/BasisNetworkCore/Serializable/VoiceReceiversMessage.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ public void Deserialize(NetDataReader reader, bool largeCount)
4141

4242
if (count == 0)
4343
{
44+
// Explicit "no recipients": use a non-null empty array so the consumer
45+
// (BasisSavedState.AddLastData) treats this as a real clear. A null Users
46+
// means "couldn't parse / corrupt" and is deliberately left for the consumer
47+
// to ignore (keep the last-known recipients).
4448
ReturnPool();
45-
Users = null;
49+
Users = Array.Empty<ushort>();
4650
UsersLength = 0;
4751
return;
4852
}
@@ -133,12 +137,14 @@ public void Serialize(NetDataWriter writer, bool largeCount)
133137
/// </summary>
134138
public void ReturnPool()
135139
{
136-
if (Users != null)
140+
// Only pool-rented arrays (length > 0) go back to the pool — never the
141+
// Array.Empty<ushort>() "explicit empty" sentinel, and never null.
142+
if (Users != null && Users.Length != 0)
137143
{
138144
ArrayPool<ushort>.Shared.Return(Users);
139-
Users = null;
140-
UsersLength = 0;
141145
}
146+
Users = null;
147+
UsersLength = 0;
142148
}
143149

144150
private static void SkipRemaining(NetDataReader reader)

Basis/Packages/com.basis.eventdriver/BasisEventDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private void OnBeforeRender()
391391
/// <summary>
392392
/// Application quit hook. Disposes physics and stops microphone processing.
393393
/// </summary>
394-
public async void OnApplicationQuit()
394+
public void OnApplicationQuit()
395395
{
396396
JigglePhysics.Dispose();
397397
#if !BASIS_DISABLE_MICROPHONE

Basis/Packages/com.basis.framework.editor/Editor/BasisAvatarRecorderEditor.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,6 @@ private void LoadAndConvert()
553553

554554
private void ConvertFileToAnimationClip(string path)
555555
{
556-
if (BasisAvatarRecorder.BytesPerFrame <= 0)
557-
return;
558-
559556
if (!File.Exists(path))
560557
{
561558
EditorUtility.DisplayDialog("Convert to AnimationClip", $"File not found:\n{path}", "OK");

Basis/Packages/com.basis.framework.editor/Editor/BasisBeeExplorerWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private void OnDestroy()
4848
}
4949
}
5050

51-
public async void OnGUI()
51+
public void OnGUI()
5252
{
5353
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
5454

Basis/Packages/com.basis.framework.editor/Editor/BasisHeadlessBuild.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private static void BuildServer(BuildTarget target)
5858
if (target == BuildTarget.StandaloneLinux64)
5959
{
6060
int linuxArchitecture = ParseLinuxArchitecture(linuxArchitectureArg);
61-
PlayerSettings.SetArchitecture(targetGroup, linuxArchitecture);
61+
PlayerSettings.SetArchitecture(NamedBuildTarget.FromBuildTargetGroup(targetGroup), linuxArchitecture);
6262
Debug.Log($"[BasisHeadlessBuild] Linux architecture(set)={linuxArchitecture}");
6363
}
6464
Debug.Log($"[BasisHeadlessBuild] activeBuildTarget(after)={EditorUserBuildSettings.activeBuildTarget}");

Basis/Packages/com.basis.framework/Avatar/BasisAvatarFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,11 @@ private static async Task<SemaphoreSlim> ResolveGate(byte Mode, BasisLoadableBun
608608
}
609609

610610
// Tracks the latest in-flight request per player (local/remote share this).
611-
private static readonly ConcurrentDictionary<int, CancellationTokenSource> _playerLoadCts = new();
611+
private static readonly ConcurrentDictionary<EntityId, CancellationTokenSource> _playerLoadCts = new();
612612

613613
private static CancellationToken ReplacePlayerLoadToken(BasisPlayer player)
614614
{
615-
int key = player.GetEntityId();
615+
EntityId key = player.GetEntityId();
616616

617617
// Cancel & dispose previous request (if any)
618618
if (_playerLoadCts.TryRemove(key, out var old))
@@ -628,7 +628,7 @@ private static CancellationToken ReplacePlayerLoadToken(BasisPlayer player)
628628

629629
private static void ClearPlayerLoadToken(BasisPlayer player, CancellationToken token)
630630
{
631-
int key = player.GetEntityId();
631+
EntityId key = player.GetEntityId();
632632
if (_playerLoadCts.TryGetValue(key, out var cts) && cts.Token == token)
633633
{
634634
_playerLoadCts.TryRemove(key, out _);
@@ -643,7 +643,7 @@ private static void ClearPlayerLoadToken(BasisPlayer player, CancellationToken t
643643
public static void CancelPlayerLoad(BasisPlayer player)
644644
{
645645
if (player == null) return;
646-
int key = player.GetEntityId();
646+
EntityId key = player.GetEntityId();
647647
if (_playerLoadCts.TryRemove(key, out var cts))
648648
{
649649
try { cts.Cancel(); } catch { /* ignore */ }

Basis/Packages/com.basis.framework/Avatar/BasisAvatarModelCache.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// player switching back, or multiple remote players sharing the same model — skips
1010
/// the expensive bake/capture work and copies from cache instead.
1111
///
12-
/// Cache key: <c>Animator.avatar.GetInstanceID()</c> — unique per loaded Avatar asset,
12+
/// Cache key: <c>Animator.avatar.GetEntityId()</c> — unique per loaded Avatar asset,
1313
/// stable across instances of the same model within a session.
1414
///
1515
/// Subsystems store their data in typed slots on <see cref="Entry"/>. A null slot means
@@ -124,21 +124,21 @@ public class BonePresenceData
124124
// Storage
125125
// ────────────────────────────────────────────────────────────
126126

127-
private static readonly Dictionary<int, Entry> _cache = new Dictionary<int, Entry>(16);
127+
private static readonly Dictionary<EntityId, Entry> _cache = new Dictionary<EntityId, Entry>(16);
128128

129129
/// <summary>
130130
/// Gets the cache key for an animator's avatar asset.
131-
/// Returns 0 if the avatar is null (caller should skip caching).
131+
/// Returns <see cref="EntityId.None"/> if the avatar is null (caller should skip caching).
132132
/// </summary>
133-
public static int GetKey(Animator animator)
133+
public static EntityId GetKey(Animator animator)
134134
{
135-
return animator != null && animator.avatar != null ? animator.avatar.GetInstanceID() : 0;
135+
return animator != null && animator.avatar != null ? animator.avatar.GetEntityId() : EntityId.None;
136136
}
137137

138138
/// <summary>
139139
/// Gets or creates the cache entry for the given avatar asset key.
140140
/// </summary>
141-
public static Entry GetOrCreate(int key)
141+
public static Entry GetOrCreate(EntityId key)
142142
{
143143
if (!_cache.TryGetValue(key, out Entry entry))
144144
{
@@ -151,15 +151,15 @@ public static Entry GetOrCreate(int key)
151151
/// <summary>
152152
/// Tries to get an existing cache entry. Returns false if not cached.
153153
/// </summary>
154-
public static bool TryGet(int key, out Entry entry)
154+
public static bool TryGet(EntityId key, out Entry entry)
155155
{
156156
return _cache.TryGetValue(key, out entry);
157157
}
158158

159159
/// <summary>
160160
/// Removes a specific avatar's cache entry (e.g., when its bundle is unloaded).
161161
/// </summary>
162-
public static void Remove(int key)
162+
public static void Remove(EntityId key)
163163
{
164164
_cache.Remove(key);
165165
}
@@ -190,10 +190,10 @@ public static void Clear()
190190
/// </summary>
191191
public static void RecordPosesCached(Basis.Scripts.Common.BasisTransformMapping mapping, Animator animator)
192192
{
193-
int key = GetKey(animator);
193+
EntityId key = GetKey(animator);
194194

195195
// Cache hit: restore from arrays
196-
if (key != 0 && TryGet(key, out var entry) && entry.TposeLocal != null && entry.TposeFromRoot != null && entry.TposeWorld != null)
196+
if (key != EntityId.None && TryGet(key, out var entry) && entry.TposeLocal != null && entry.TposeFromRoot != null && entry.TposeWorld != null)
197197
{
198198
RestorePosesFromCache(mapping, animator, entry);
199199
return;
@@ -203,13 +203,13 @@ public static void RecordPosesCached(Basis.Scripts.Common.BasisTransformMapping
203203
mapping.RecordPoses(animator);
204204

205205
// Store for next time
206-
if (key != 0)
206+
if (key != EntityId.None)
207207
{
208208
StorePosesToCache(key, mapping);
209209
}
210210
}
211211

212-
private static void StorePosesToCache(int key, Basis.Scripts.Common.BasisTransformMapping mapping)
212+
private static void StorePosesToCache(EntityId key, Basis.Scripts.Common.BasisTransformMapping mapping)
213213
{
214214
var entry = GetOrCreate(key);
215215
int boneCount = (int)HumanBodyBones.LastBone;

Basis/Packages/com.basis.framework/Avatar/BasisAvatarTextureStats.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static BasisAvatarTextureStats Collect(Renderer[] renderers, long downloa
6060
return stats;
6161

6262
// Track unique textures by instance ID to avoid double-counting shared textures.
63-
var seen = new HashSet<int>();
63+
var seen = new HashSet<EntityId>();
6464

6565
for (int r = 0; r < renderers.Length; r++)
6666
{
@@ -88,7 +88,7 @@ public static BasisAvatarTextureStats Collect(Renderer[] renderers, long downloa
8888
Texture tex = mat.GetTexture(propName);
8989

9090
if (tex == null) continue;
91-
if (!seen.Add(tex.GetInstanceID())) continue;
91+
if (!seen.Add(tex.GetEntityId())) continue;
9292

9393
Texture2D tex2D = tex as Texture2D;
9494
bool isStreaming = tex2D != null && tex2D.streamingMipmaps;

Basis/Packages/com.basis.framework/Camera/CopyColorToRTFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ public static void EnsureRT(in RenderingData renderingData, Settings settings)
112112
if (settings.forceHDR)
113113
{
114114
var requested = GraphicsFormat.R16G16B16A16_SFloat;
115-
desc.graphicsFormat = SystemInfo.GetCompatibleFormat(requested, FormatUsage.Render);
115+
desc.graphicsFormat = SystemInfo.GetCompatibleFormat(requested, GraphicsFormatUsage.Render);
116116
}
117117
else
118118
{
119119
// Keep camera's format, but ensure it's actually renderable on the platform.
120-
desc.graphicsFormat = SystemInfo.GetCompatibleFormat(camDesc.graphicsFormat, FormatUsage.Render);
120+
desc.graphicsFormat = SystemInfo.GetCompatibleFormat(camDesc.graphicsFormat, GraphicsFormatUsage.Render);
121121
}
122122

123123
bool needsRebuild =

Basis/Packages/com.basis.framework/Device Management/Devices/Headless/BasisHeadlessManagement.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void OnSceneLoadeded(Scene arg0, Scene arg1)
7777
/// </summary>
7878
private void RemoveAllMaterialTextures()
7979
{
80-
Renderer[] renderers = FindObjectsByType<Renderer>(FindObjectsInactive.Include, FindObjectsSortMode.None);
80+
Renderer[] renderers = FindObjectsByType<Renderer>(FindObjectsInactive.Include);
8181
HashSet<Material> processedMats = new HashSet<Material>();
8282

8383
foreach (Renderer renderer in renderers)
@@ -181,7 +181,7 @@ public static void ClearAllKnownTextures(Material material)
181181
/// </summary>
182182
private void RemoveAllReflectionProbes()
183183
{
184-
ReflectionProbe[] probes = FindObjectsByType<ReflectionProbe>(FindObjectsInactive.Include, FindObjectsSortMode.None);
184+
ReflectionProbe[] probes = FindObjectsByType<ReflectionProbe>(FindObjectsInactive.Include);
185185
foreach (ReflectionProbe probe in probes)
186186
{
187187
Destroy(probe.gameObject);
@@ -214,7 +214,7 @@ private void RemoveSceneCubemapReferences()
214214

215215
private void RemoveAllLightmapReferences()
216216
{
217-
Renderer[] renderers = FindObjectsByType<Renderer>(FindObjectsInactive.Include, FindObjectsSortMode.None);
217+
Renderer[] renderers = FindObjectsByType<Renderer>(FindObjectsInactive.Include);
218218
foreach (Renderer renderer in renderers)
219219
{
220220
if (renderer == null)
@@ -244,7 +244,7 @@ private void RemoveAllLightmapReferences()
244244
/// </summary>
245245
private void RemoveAllText()
246246
{
247-
Canvas[] canvases = FindObjectsByType<Canvas>(FindObjectsInactive.Include, FindObjectsSortMode.None);
247+
Canvas[] canvases = FindObjectsByType<Canvas>(FindObjectsInactive.Include);
248248
foreach (Canvas canvas in canvases)
249249
{
250250
Destroy(canvas);

0 commit comments

Comments
 (0)