Skip to content

Commit c93a652

Browse files
authored
fix(misc): scattered null/dispose/cancellation robustness across auth, map, plugins, init
1 parent e15a8cc commit c93a652

41 files changed

Lines changed: 155 additions & 82 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Explorer/Assets/DCL/AssetsProvision/Contextual/ContextualImage.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ private async UniTask LoadAsync()
5151

5252
private void OnDisable()
5353
{
54-
image.sprite = null!;
55-
asset.Release();
54+
if (image != null)
55+
image.sprite = null!;
56+
asset?.Release();
5657
}
5758

5859
private void OnDestroy()
5960
{
60-
image.sprite = null!;
61-
asset.Dispose();
61+
if (image != null)
62+
image.sprite = null!;
63+
asset?.Dispose();
6264
}
6365

6466
public UniTask TriggerOrWaitReadyAsync(CancellationToken token) =>

Explorer/Assets/DCL/AuthenticationScreenFlow/AuthenticationScreenAudio.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void OnMuteButtonClicked()
6262

6363
private void OnContinuousAudioStarted(AudioClipConfig audioClipConfig)
6464
{
65-
if (audioClipConfig.GetInstanceID() != backgroundMusic.GetInstanceID())
65+
if (audioClipConfig.GetEntityId() != backgroundMusic.GetEntityId())
6666
return;
6767

6868
UIAudioEventsBus.Instance.PlayContinuousUIAudioEvent -= OnContinuousAudioStarted;

Explorer/Assets/DCL/AuthenticationScreenFlow/Views/LobbyForExistingAccountAuthView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public void Show(string profileName)
4646
JumpIntoWorldButton.interactable = true;
4747
DiffAccountButton.interactable = true;
4848

49-
ShowAsync(CancellationToken.None).Forget();
49+
ShowAsync(destroyCancellationToken).Forget();
5050
}
5151

5252
public void Hide(int animHash)
5353
{
5454
hideAnimHash = animHash;
55-
HideAsync(CancellationToken.None).Forget();
55+
HideAsync(destroyCancellationToken).Forget();
5656
}
5757

5858
public override async UniTask ShowAsync(CancellationToken ct)

Explorer/Assets/DCL/AuthenticationScreenFlow/Views/LobbyForNewAccountAuthView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ private async UniTaskVoid UpdateBodyTypeLabelAsync(bool isMale)
106106

107107
public void Show()
108108
{
109-
ShowAsync(CancellationToken.None).Forget();
109+
ShowAsync(destroyCancellationToken).Forget();
110110
}
111111

112112
public void Hide(int animHash)
113113
{
114114
hideAnimHash = animHash;
115-
HideAsync(CancellationToken.None).Forget();
115+
HideAsync(destroyCancellationToken).Forget();
116116
}
117117

118118
public override async UniTask ShowAsync(CancellationToken ct)

Explorer/Assets/DCL/AuthenticationScreenFlow/Views/LoginSelectionAuthView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private void SetOptionsPanelVisibility(bool isExpanded)
106106
public void Show(int animHash, bool moreOptionsExpanded)
107107
{
108108
showAnimHash = animHash;
109-
ShowAsync(CancellationToken.None).Forget();
109+
ShowAsync(destroyCancellationToken).Forget();
110110

111111
areOptionsExpanded = moreOptionsExpanded;
112112
SetOptionsPanelVisibility(areOptionsExpanded);
@@ -120,7 +120,7 @@ public void Hide()
120120
loadingSpinner.SetActive(false);
121121
SetEmailInputFieldSpinnerActive(false);
122122

123-
HideAsync(CancellationToken.None).Forget();
123+
HideAsync(destroyCancellationToken).Forget();
124124
}
125125

126126
public void SetLoadingSpinnerVisibility(bool isLoading)

Explorer/Assets/DCL/AuthenticationScreenFlow/Views/ProfileFetchingAuthView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public class ProfileFetchingAuthView : ViewBase
2323

2424
public void Show()
2525
{
26-
ShowAsync(CancellationToken.None).Forget();
26+
ShowAsync(destroyCancellationToken).Forget();
2727
}
2828

2929
public void Hide(int hideAnimHash)
3030
{
3131
this.hideAnimHash = hideAnimHash;
32-
HideAsync(CancellationToken.None).Forget();
32+
HideAsync(destroyCancellationToken).Forget();
3333
}
3434

3535
public override async UniTask ShowAsync(CancellationToken ct)

Explorer/Assets/DCL/AuthenticationScreenFlow/Views/VerificationDappAuthView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public void Show(int dataCode, DateTime expiration)
6060
code.text = dataCode.ToString();
6161
DoCountdownAsync(expiration).Forget();
6262

63-
ShowAsync(CancellationToken.None).Forget();
63+
ShowAsync(destroyCancellationToken).Forget();
6464
}
6565

6666
public void Hide(int hideAnimHash)
6767
{
6868
this.hideAnimHash = hideAnimHash;
69-
HideAsync(CancellationToken.None).Forget();
69+
HideAsync(destroyCancellationToken).Forget();
7070
}
7171

7272
public override async UniTask ShowAsync(CancellationToken ct)

Explorer/Assets/DCL/AuthenticationScreenFlow/Views/VerificationOTPAuthView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public class VerificationOTPAuthView : ViewBase
3333
public void Show(string email)
3434
{
3535
InputField.Clear();
36-
ShowAsync(CancellationToken.None).Forget();
36+
ShowAsync(destroyCancellationToken).Forget();
3737
description.text = description.text.Replace("your@email.com", email); // Update description with user email
3838
}
3939

4040
public void Hide(int hideAnimHash)
4141
{
4242
this.hideAnimHash = hideAnimHash;
43-
HideAsync(CancellationToken.None).Forget();
43+
HideAsync(destroyCancellationToken).Forget();
4444
}
4545

4646
public override async UniTask ShowAsync(CancellationToken ct)

Explorer/Assets/DCL/AvatarRendering/AvatarShape/Components/AvatarCustomSkinningComponent.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ public void AssignBuffer(ComputeSkinningBufferContainer container)
4545

4646
public void DisposeBuffers()
4747
{
48-
computeSkinningBufferContainer.Dispose();
49-
bones.Dispose();
48+
// a default(Buffers) (empty avatar) owns nothing to dispose
49+
computeSkinningBufferContainer?.Dispose();
50+
bones?.Dispose();
5051
}
5152
}
5253

@@ -117,6 +118,10 @@ public readonly void SetFadingDistance(float distance)
117118

118119
public Result ComputeSkinning(NativeArray<float4x4> bonesResult, GlobalJobArrayIndex indexInGlobalJobArray)
119120
{
121+
// an empty avatar (no vertices) has nothing to skin
122+
if (VertCount == 0)
123+
return Result.SuccessResult();
124+
120125
if (indexInGlobalJobArray.TryGetValue(out int validIndex) == false)
121126
{
122127
return Result.ErrorResult("Attempt to process an invalid avatar");

Explorer/Assets/DCL/AvatarRendering/AvatarShape/ComputeShader/ComputeShaderSkinning.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ public override AvatarCustomSkinningComponent Initialize(IList<CachedAttachment>
2828

2929
(int vertCount, int totalBoneBufferCount) = SetupCounters(meshesData, boneCount);
3030

31+
if (vertCount == 0 || boneCount == 0)
32+
{
33+
ReportHub.LogWarning(ReportCategory.AVATAR,
34+
$"[ComputeShaderSkinning] Empty avatar mesh data (vertCount={vertCount}, boneCount={boneCount}); skipping skinning.");
35+
ListPool<MeshData>.Release(meshesData);
36+
37+
// VertCount == 0 with default Buffers marks the component as empty: ComputeSkinning and
38+
// DisposeBuffers no-op on it, and the materials list is pool-rented so Dispose's
39+
// unconditional USED_SLOTS_POOL.Release stays balanced.
40+
return new AvatarCustomSkinningComponent(0, 0, default, AvatarCustomSkinningComponent.USED_SLOTS_POOL.Get(), skinningShader, default);
41+
}
42+
3143
AvatarCustomSkinningComponent.Buffers buffers = SetupComputeShader(meshesData, skinningShader, vertCount, totalBoneBufferCount, boneCount);
3244
List<AvatarCustomSkinningComponent.MaterialSetup> materialSetups = SetupMeshRenderer(meshesData, avatarMaterialPool, avatarShapeComponent, facialFeatureTexture);
3345

0 commit comments

Comments
 (0)