gg.easy.airship 0.1.2143 → 0.1.2145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/Editor/LuauPluginUpdateCheck.cs +1 -1
  2. package/Editor/TypescriptServices/TypescriptServices.cs +5 -1
  3. package/Runtime/Code/Airship/Resources/Scripts/MaterialColorURP.cs +11 -1
  4. package/Runtime/Code/AirshipConst.cs +2 -2
  5. package/Runtime/Code/Auth/AuthManager.cs +4 -0
  6. package/Runtime/Code/Authentication/EasyAuthenticator.cs +2 -2
  7. package/Runtime/Code/Authentication/TransferData.cs +1 -1
  8. package/Runtime/Code/Bootstrap/ClientBundleLoader.cs +1 -1
  9. package/Runtime/Code/Bootstrap/LuauScriptsDtoSerializer.cs +48 -19
  10. package/Runtime/Code/Bundles/AirshipLuauDebugger.cs +0 -5
  11. package/Runtime/Code/Bundles/SystemRoot.cs +1 -1
  12. package/Runtime/Code/Easy.Airship.asmdef +2 -1
  13. package/Runtime/Code/GoogleSignIn/GoogleSignIn.asmdef +15 -2
  14. package/Runtime/Code/GoogleSignIn/Plugins/iOS/GoogleSignIn.h.meta +13 -12
  15. package/Runtime/Code/GoogleSignIn/Plugins/iOS/GoogleSignIn.mm.meta +13 -12
  16. package/Runtime/Code/GoogleSignIn/Plugins/iOS/GoogleSignInAppController.h.meta +13 -12
  17. package/Runtime/Code/GoogleSignIn/Plugins/iOS/GoogleSignInAppController.mm.meta +13 -12
  18. package/Runtime/Code/Health/AirshipProfileExporter.cs +15 -10
  19. package/Runtime/Code/Luau/AirshipComponent.cs +33 -8
  20. package/Runtime/Code/Luau/LuauCore.cs +1 -1
  21. package/Runtime/Code/Luau/LuauCoreCallbacks.cs +80 -107
  22. package/Runtime/Code/Luau/LuauCoreReflection.cs +10 -8
  23. package/Runtime/Code/Luau/LuauCoreUtilities.cs +5 -5
  24. package/Runtime/Code/Luau/LuauMetadata.cs +2 -0
  25. package/Runtime/Code/Luau/LuauPlugin.cs +40 -33
  26. package/Runtime/Code/Luau/ReflectionList.cs +28 -0
  27. package/Runtime/Code/Luau/RendererAPI.cs +11 -3
  28. package/Runtime/Code/Luau/ThreadManager.cs +0 -11
  29. package/Runtime/Code/Network/ServerConsole.cs +22 -8
  30. package/Runtime/Code/Player/Character/Animation/ClipReplacer/AnimatorClipReplacer.cs +16 -26
  31. package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovement.cs +215 -112
  32. package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovementSettings.cs +16 -6
  33. package/Runtime/Code/Player/PlayerInfo.cs +4 -0
  34. package/Runtime/Code/Player/PlayerManagerBridge.cs +3 -2
  35. package/Runtime/Code/VoiceChat/AirshipUniVoiceNetwork.cs +1 -1
  36. package/Runtime/Code/VoxelWorld/ChunkSerializer.cs +37 -30
  37. package/Runtime/Code/Zstd/Zstd.cs +85 -19
  38. package/Runtime/DevConsole/Runtime/DevConsoleMono.cs +2 -0
  39. package/Runtime/Plugins/Android/libLuauPlugin.so +0 -0
  40. package/Runtime/Plugins/Linux/libLuauPlugin.so +0 -0
  41. package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin +0 -0
  42. package/Runtime/Plugins/Windows/x64/LuauPlugin.dll +0 -0
  43. package/Runtime/Plugins/Windows/x64/LuauPlugin.pdb +0 -0
  44. package/Runtime/Plugins/iOS/LuauPluginIos.a +0 -0
  45. package/ThirdParty/Mirror/Core/NetworkClient.cs +1 -1
  46. package/ThirdParty/Mirror/Core/NetworkManager.cs +2 -2
  47. package/package.json +1 -1
@@ -57,7 +57,7 @@ public static class LuauPluginUpdateCheck {
57
57
  if (lastHash != "") {
58
58
  // Check if user wants to restart
59
59
  var acceptsRestart = EditorUtility.DisplayDialog("Luau Plugin Updated",
60
- "The Luau plugin has updated. Restart Unity to apply changes. We're sorry for this..", "Quit", "Cancel");
60
+ "Airship Luau plugin has updated. Restart Unity to apply changes.", "Quit", "Cancel");
61
61
  if (acceptsRestart) {
62
62
  // Verify any unsaved changes are saved
63
63
  var confirmedSaveState = EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
@@ -163,7 +163,11 @@ namespace Airship.Editor {
163
163
  private static IEnumerator StartTypescriptRuntime() {
164
164
  TypescriptProjectsService.ReloadProject();
165
165
 
166
- // if (!EditorIntegrationsConfig.instance.typescriptAutostartCompiler) yield break;
166
+ // Wait for updates
167
+ if (AirshipUpdateService.IsUpdatingAirship || AirshipPackagesWindow.IsModifyingPackages) {
168
+ yield return new WaitUntil(() =>
169
+ !AirshipPackagesWindow.IsModifyingPackages && !AirshipUpdateService.IsUpdatingAirship);
170
+ }
167
171
 
168
172
  if (TypescriptCompilationService.IsWatchModeRunning) {
169
173
  TypescriptCompilationService.StopCompilerServices(true);
@@ -62,7 +62,17 @@ public class MaterialColorURP : MonoBehaviour {
62
62
 
63
63
  // Called when the color is changed in the inspector
64
64
  private void OnValidate() {
65
- DoUpdate();
65
+ #if UNITY_EDITOR
66
+ if (Application.isPlaying) {
67
+ DoUpdate();
68
+ } else {
69
+ EditorApplication.delayCall += () => {
70
+ if (this != null) DoUpdate();
71
+ };
72
+ }
73
+ #else
74
+ DoUpdate();
75
+ #endif
66
76
  }
67
77
 
68
78
  private void OnDestroy() {
@@ -1,11 +1,11 @@
1
1
  // ReSharper disable InconsistentNaming
2
2
  namespace Code {
3
3
  public static class AirshipConst {
4
- public const int playerVersion = 8;
4
+ public const int playerVersion = 9;
5
5
 
6
6
  /// <summary>
7
7
  /// The server will kick clients that have a playerVersion lower than this value.
8
8
  /// </summary>
9
- public const int minAcceptedPlayerVersionOnServer = 8;
9
+ public const int minAcceptedPlayerVersionOnServer = 9;
10
10
  }
11
11
  }
@@ -5,7 +5,9 @@ using Cdm.Authentication.Browser;
5
5
  using Cdm.Authentication.Clients;
6
6
  using Cdm.Authentication.OAuth2;
7
7
  using Code.Http.Internal;
8
+ #if UNITY_ANDROID
8
9
  using Google;
10
+ #endif
9
11
  using JetBrains.Annotations;
10
12
  using Proyecto26;
11
13
  using RSG;
@@ -112,6 +114,7 @@ public class AuthManager {
112
114
  scope = "openid email profile",
113
115
  });
114
116
 
117
+ #if UNITY_ANDROID
115
118
  GoogleSignIn.Configuration = new GoogleSignInConfiguration() {
116
119
  RequestEmail = true,
117
120
  RequestProfile = true,
@@ -121,6 +124,7 @@ public class AuthManager {
121
124
  ClientSecret = clientSecret,
122
125
  #endif
123
126
  };
127
+ #endif
124
128
 
125
129
  #if AIRSHIP_ANDROID_DEBUG
126
130
  GoogleSignIn.DefaultInstance.EnableDebugLogging(true);
@@ -205,14 +205,14 @@ namespace Code.Authentication {
205
205
  }
206
206
 
207
207
  })).Then((res) => {
208
- // print($"[Transfer Packet] userIdToken: {userIdToken}, packet response: " + res.Text);
208
+ // print($"[Transfer Packet] {res.Text}");
209
209
  string fullTransferPacket = res.Text;
210
210
  TransferData transferData = JsonUtility.FromJson<TransferData>(fullTransferPacket);
211
211
  tcs.SetResult(new UserData() {
212
212
  uid = transferData.user.uid,
213
213
  username = transferData.user.username,
214
214
  profileImageId = transferData.user.profileImageId,
215
- orgRoleName = transferData.user.orgRoleName,
215
+ orgRoleName = transferData.orgRoleName,
216
216
  fullTransferPacket = fullTransferPacket
217
217
  });
218
218
  }).Catch((err) => {
@@ -12,11 +12,11 @@ public class User {
12
12
  public string usernameLower;
13
13
  public string lastUsernameChangeTime;
14
14
  public string profileImageId;
15
- public string orgRoleName;
16
15
  }
17
16
 
18
17
 
19
18
  [Serializable]
20
19
  public class TransferData {
21
20
  public User user;
21
+ public string orgRoleName;
22
22
  }
@@ -252,7 +252,7 @@ namespace Code.Bootstrap {
252
252
 
253
253
  this.codeReceiveSt.Restart();
254
254
 
255
- print("Requesting scripts from server..");
255
+ print("[Airship] Requesting scripts from server...");
256
256
  NetworkClient.Send(new RequestScriptsMessage());
257
257
  }
258
258
 
@@ -1,14 +1,36 @@
1
1
  using System;
2
+ using System.Buffers;
2
3
  using System.Collections.Generic;
3
4
  using System.IO;
4
5
  using System.IO.Compression;
5
6
  using Mirror;
6
7
  using UnityEngine;
8
+ using UnityEngine.Profiling;
7
9
 
8
10
  namespace Code.Bootstrap {
11
+
12
+ class CachedCompressedFile {
13
+ public byte[] compressedBytes;
14
+ public int compressedLength;
15
+
16
+ public CachedCompressedFile(byte[] compressedBytes, int compressedLength) {
17
+ this.compressedBytes = compressedBytes;
18
+ this.compressedLength = compressedLength;
19
+ }
20
+ }
21
+
9
22
  public static class LuauScriptsDtoSerializer {
23
+ private static Zstd.Zstd zstd = new(1024 * 4);
24
+ private static readonly Dictionary<string, CachedCompressedFile> compressedFileCache = new();
25
+
26
+ [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
27
+ private static void OnReload() {
28
+ compressedFileCache.Clear();
29
+ }
30
+
10
31
  public static void WriteLuauScriptsDto(this NetworkWriter writer, LuauScriptsDto scripts) {
11
- writer.WriteInt(scripts.files.Count);;
32
+ Profiler.BeginSample("WriteLuauScriptsDto");
33
+ writer.WriteInt(scripts.files.Count);
12
34
  foreach (var pair in scripts.files) {
13
35
  string packageId = pair.Key;
14
36
  writer.WriteString(packageId);
@@ -16,22 +38,30 @@ namespace Code.Bootstrap {
16
38
  foreach (var file in pair.Value) {
17
39
  writer.WriteString(file.path);
18
40
 
19
- // Compress the byte array
20
- byte[] compressedBytes;
21
- using (MemoryStream ms = new MemoryStream()) {
22
- using (DeflateStream deflateStream = new DeflateStream(ms, CompressionMode.Compress)) {
23
- deflateStream.Write(file.bytes, 0, file.bytes.Length);
24
- }
25
- compressedBytes = ms.ToArray();
41
+ string cacheId = $"{packageId}:{file.path}";
42
+ if (compressedFileCache.TryGetValue(cacheId, out var cache)) {
43
+ writer.WriteInt(cache.compressedLength);
44
+ writer.WriteBytes(cache.compressedBytes, 0, cache.compressedLength);
45
+ } else {
46
+ // Compress the byte array
47
+ Profiler.BeginSample("Luau Compress");
48
+ var maxCompressionSize = Zstd.Zstd.GetCompressionBound(file.bytes);
49
+ byte[] compressedBytes = new byte[maxCompressionSize];
50
+ var compressedSize = zstd.Compress(file.bytes, compressedBytes);
51
+ writer.WriteInt(compressedSize);
52
+ writer.WriteBytes(compressedBytes, 0, compressedSize);
53
+
54
+ compressedFileCache.Add(cacheId, new CachedCompressedFile(compressedBytes, compressedSize));
26
55
  }
27
- writer.WriteArray(compressedBytes);
56
+
28
57
  writer.WriteBool(file.airshipBehaviour);
58
+ Profiler.EndSample();
29
59
  }
30
60
  }
61
+ Profiler.EndSample();
31
62
  }
32
63
 
33
64
  public static LuauScriptsDto ReadLuauScriptsDto(this NetworkReader reader) {
34
- var totalBytes = reader.Remaining;
35
65
  LuauScriptsDto dto = new LuauScriptsDto();
36
66
  int packagesLength = reader.ReadInt();
37
67
  for (int pkgI = 0; pkgI < packagesLength; pkgI++) {
@@ -44,15 +74,14 @@ namespace Code.Bootstrap {
44
74
  LuauFileDto script = new LuauFileDto();
45
75
  script.path = reader.ReadString();
46
76
 
47
- var byteArray = reader.ReadArray<byte>();
48
- using (MemoryStream compressedStream = new MemoryStream(byteArray)) {
49
- using (DeflateStream deflateStream = new DeflateStream(compressedStream, CompressionMode.Decompress)) {
50
- using (MemoryStream outputStream = new MemoryStream()) {
51
- deflateStream.CopyTo(outputStream);
52
- script.bytes = outputStream.ToArray();
53
- }
54
- }
55
- }
77
+ // Read the compressed bytes
78
+ var compressedBytesLen = reader.ReadInt();
79
+ byte[] compressedBytes = ArrayPool<byte>.Shared.Rent(compressedBytesLen);
80
+ reader.ReadBytes(compressedBytes, compressedBytesLen);
81
+
82
+ // Decompress the bytes
83
+ script.bytes = new byte[Zstd.Zstd.GetDecompressionBound(compressedBytes)];
84
+ zstd.Decompress(new ReadOnlySpan<byte>(compressedBytes, 0, compressedBytesLen), script.bytes);
56
85
 
57
86
  script.airshipBehaviour = reader.ReadBool();
58
87
 
@@ -68,11 +68,6 @@ public class AirshipLuauDebugger : NetworkBehaviour {
68
68
  var n = "(Destroyed)";
69
69
  if (unityObj != null) {
70
70
  n = unityObj.name;
71
- } else {
72
- var cachedName = ThreadDataManager.GetObjectReferenceName_TEMP_DEBUG(instanceId);
73
- if (cachedName != null) {
74
- n = cachedName + " (Destroyed)";
75
- }
76
71
  }
77
72
  var objName = $"[{t.Name}] {n}";
78
73
  if (!countByName.TryAdd(objName, 1)) {
@@ -324,7 +324,7 @@ public class SystemRoot : Singleton<SystemRoot> {
324
324
 
325
325
  #if AIRSHIP_PLAYER || true
326
326
  try {
327
- Debug.Log("Scanning network prefabs...");
327
+ // Debug.Log("Scanning network prefabs...");
328
328
  Debug.Log($"Listing {NetworkClient.prefabs.Count} network prefabs:");
329
329
  int i = 1;
330
330
  foreach (var pair in NetworkClient.prefabs) {
@@ -52,7 +52,8 @@
52
52
  "GUID:325984b52e4128546bc7558552f8b1d2",
53
53
  "GUID:3b5390adca4e2bb4791cb930316d6f3e",
54
54
  "GUID:725ee7191c021de4dbf9269590ded755",
55
- "GUID:2a0340569ab0e1245a38e0d6c7b2529b"
55
+ "GUID:2a0340569ab0e1245a38e0d6c7b2529b",
56
+ "GUID:befe48b9a36afc04ea625c93daad910e"
56
57
  ],
57
58
  "includePlatforms": [],
58
59
  "excludePlatforms": [],
@@ -1,3 +1,16 @@
1
1
  {
2
- "name": "GoogleSignin"
3
- }
2
+ "name": "GoogleSignin",
3
+ "rootNamespace": "",
4
+ "references": [],
5
+ "includePlatforms": [],
6
+ "excludePlatforms": [
7
+ "iOS"
8
+ ],
9
+ "allowUnsafeCode": false,
10
+ "overrideReferences": false,
11
+ "precompiledReferences": [],
12
+ "autoReferenced": true,
13
+ "defineConstraints": [],
14
+ "versionDefines": [],
15
+ "noEngineReferences": false
16
+ }
@@ -5,7 +5,7 @@ labels:
5
5
  - gvh_version-1.0.4
6
6
  PluginImporter:
7
7
  externalObjects: {}
8
- serializedVersion: 2
8
+ serializedVersion: 3
9
9
  iconMap: {}
10
10
  executionOrder: {}
11
11
  defineConstraints: []
@@ -14,21 +14,22 @@ PluginImporter:
14
14
  isExplicitlyReferenced: 0
15
15
  validateReferences: 1
16
16
  platformData:
17
- - first:
18
- Any:
19
- second:
17
+ Any:
20
18
  enabled: 0
21
- settings: {}
22
- - first:
23
- Editor: Editor
24
- second:
19
+ settings:
20
+ Exclude Android: 1
21
+ Exclude Editor: 1
22
+ Exclude Linux64: 1
23
+ Exclude OSXUniversal: 1
24
+ Exclude Win: 1
25
+ Exclude Win64: 1
26
+ Exclude iOS: 1
27
+ Editor:
25
28
  enabled: 0
26
29
  settings:
27
30
  DefaultValueInitialized: true
28
- - first:
29
- iPhone: iOS
30
- second:
31
- enabled: 1
31
+ iOS:
32
+ enabled: 0
32
33
  settings: {}
33
34
  userData:
34
35
  assetBundleName:
@@ -5,7 +5,7 @@ labels:
5
5
  - gvh_version-1.0.4
6
6
  PluginImporter:
7
7
  externalObjects: {}
8
- serializedVersion: 2
8
+ serializedVersion: 3
9
9
  iconMap: {}
10
10
  executionOrder: {}
11
11
  defineConstraints: []
@@ -14,21 +14,22 @@ PluginImporter:
14
14
  isExplicitlyReferenced: 0
15
15
  validateReferences: 1
16
16
  platformData:
17
- - first:
18
- Any:
19
- second:
17
+ Any:
20
18
  enabled: 0
21
- settings: {}
22
- - first:
23
- Editor: Editor
24
- second:
19
+ settings:
20
+ Exclude Android: 1
21
+ Exclude Editor: 1
22
+ Exclude Linux64: 1
23
+ Exclude OSXUniversal: 1
24
+ Exclude Win: 1
25
+ Exclude Win64: 1
26
+ Exclude iOS: 1
27
+ Editor:
25
28
  enabled: 0
26
29
  settings:
27
30
  DefaultValueInitialized: true
28
- - first:
29
- iPhone: iOS
30
- second:
31
- enabled: 1
31
+ iOS:
32
+ enabled: 0
32
33
  settings: {}
33
34
  userData:
34
35
  assetBundleName:
@@ -5,7 +5,7 @@ labels:
5
5
  - gvh_version-1.0.4
6
6
  PluginImporter:
7
7
  externalObjects: {}
8
- serializedVersion: 2
8
+ serializedVersion: 3
9
9
  iconMap: {}
10
10
  executionOrder: {}
11
11
  defineConstraints: []
@@ -14,21 +14,22 @@ PluginImporter:
14
14
  isExplicitlyReferenced: 0
15
15
  validateReferences: 1
16
16
  platformData:
17
- - first:
18
- Any:
19
- second:
17
+ Any:
20
18
  enabled: 0
21
- settings: {}
22
- - first:
23
- Editor: Editor
24
- second:
19
+ settings:
20
+ Exclude Android: 1
21
+ Exclude Editor: 1
22
+ Exclude Linux64: 1
23
+ Exclude OSXUniversal: 1
24
+ Exclude Win: 1
25
+ Exclude Win64: 1
26
+ Exclude iOS: 1
27
+ Editor:
25
28
  enabled: 0
26
29
  settings:
27
30
  DefaultValueInitialized: true
28
- - first:
29
- iPhone: iOS
30
- second:
31
- enabled: 1
31
+ iOS:
32
+ enabled: 0
32
33
  settings: {}
33
34
  userData:
34
35
  assetBundleName:
@@ -5,7 +5,7 @@ labels:
5
5
  - gvh_version-1.0.4
6
6
  PluginImporter:
7
7
  externalObjects: {}
8
- serializedVersion: 2
8
+ serializedVersion: 3
9
9
  iconMap: {}
10
10
  executionOrder: {}
11
11
  defineConstraints: []
@@ -14,21 +14,22 @@ PluginImporter:
14
14
  isExplicitlyReferenced: 0
15
15
  validateReferences: 1
16
16
  platformData:
17
- - first:
18
- Any:
19
- second:
17
+ Any:
20
18
  enabled: 0
21
- settings: {}
22
- - first:
23
- Editor: Editor
24
- second:
19
+ settings:
20
+ Exclude Android: 1
21
+ Exclude Editor: 1
22
+ Exclude Linux64: 1
23
+ Exclude OSXUniversal: 1
24
+ Exclude Win: 1
25
+ Exclude Win64: 1
26
+ Exclude iOS: 1
27
+ Editor:
25
28
  enabled: 0
26
29
  settings:
27
30
  DefaultValueInitialized: true
28
- - first:
29
- iPhone: iOS
30
- second:
31
- enabled: 1
31
+ iOS:
32
+ enabled: 0
32
33
  settings: {}
33
34
  userData:
34
35
  assetBundleName:
@@ -1,11 +1,10 @@
1
1
  using System;
2
- using System.Diagnostics;
3
2
  using System.IO;
4
3
  using System.Threading.Tasks;
5
4
  using Airship.DevConsole;
6
5
  using Code.Http.Internal;
7
6
  using Code.Platform.Shared;
8
- using Code.UI;
7
+ using Code.Player;
9
8
  using JetBrains.Annotations;
10
9
  using Mirror;
11
10
  using UnityEngine;
@@ -56,6 +55,7 @@ namespace Code.Health
56
55
 
57
56
  public struct StartServerProfileMessage : NetworkMessage {
58
57
  public int DurationSecs;
58
+ public bool CallstacksEnabled;
59
59
  }
60
60
 
61
61
  public struct ServerProfileCompleteMessage : NetworkMessage
@@ -88,13 +88,14 @@ namespace Code.Health
88
88
  NetworkClient.RegisterHandler<ClientProfileUploadResponse>(OnClientUploadResponse);
89
89
  }
90
90
 
91
- DevConsole.AddCommand(Command.Create<string, int>(
91
+ DevConsole.AddCommand(Command.Create<string, int, bool>(
92
92
  "profile",
93
93
  "",
94
94
  "Starts and uploads a profile. Once complete the download link will be printed.",
95
95
  Parameter.Create("Context", "Options: Server | Client"),
96
96
  Parameter.Create("Duration", "Duration of profile in seconds (max 5s)"),
97
- (context, d) => {
97
+ Parameter.Create("Callstacks", "Enable callstacks for profile (this is laggy)"),
98
+ (context, d, callstacks) => {
98
99
  if (d is < 0 or > 5) {
99
100
  Debug.LogError("You can only profile for a max of 5s.");
100
101
  return;
@@ -106,10 +107,10 @@ namespace Code.Health
106
107
  "Unable to capture profile log because debug mode is not enabled. Use the development build branch on Steam to enable debug mode.");
107
108
  return;
108
109
  }
109
- StartProfiling(d, null);
110
+ StartProfiling(d, null, callstacks);
110
111
  } else if (context.Equals("server", StringComparison.OrdinalIgnoreCase)) {
111
112
  Debug.Log("Starting a server profile, view server console to monitor progress.");
112
- NetworkClient.Send(new StartServerProfileMessage { DurationSecs = d });
113
+ NetworkClient.Send(new StartServerProfileMessage { DurationSecs = d, CallstacksEnabled = callstacks });
113
114
  }
114
115
  }));
115
116
  }
@@ -142,8 +143,10 @@ namespace Code.Health
142
143
  }
143
144
 
144
145
  public void OnStartProfilingMessage(NetworkConnectionToClient sender, StartServerProfileMessage msg) {
145
- // TODO Validate sender is dev
146
- StartProfiling(msg.DurationSecs, sender);
146
+ var player = PlayerManagerBridge.Instance.GetPlayerInfoByConnectionId(sender.connectionId);
147
+ if (player.IsInGameOrg()) {
148
+ StartProfiling(msg.DurationSecs, sender, msg.CallstacksEnabled);
149
+ }
147
150
  }
148
151
 
149
152
  public async void OnServerProfileCompleteMessage(ServerProfileCompleteMessage msg)
@@ -163,7 +166,7 @@ namespace Code.Health
163
166
  GUIUtility.systemCopyBuffer = data.url;
164
167
  }
165
168
 
166
- public void StartProfiling(int durationSecs, [CanBeNull] NetworkConnectionToClient profileInitiator) {
169
+ public void StartProfiling(int durationSecs, [CanBeNull] NetworkConnectionToClient profileInitiator, bool enableCallstacks) {
167
170
  // TODO check that sender is game dev
168
171
  // if (Profiler.enabled) {
169
172
  // Debug.LogWarning("Profiler is already running.");
@@ -181,14 +184,16 @@ namespace Code.Health
181
184
  Profiler.logFile = logPath;
182
185
  Profiler.enableBinaryLog = true;
183
186
 
184
- Debug.Log($"Starting profiler for {durationSecs} seconds.");
187
+ Debug.Log($"Starting profiler for {durationSecs} seconds. Callstacks = {enableCallstacks}");
185
188
  Profiler.enabled = true;
189
+ Profiler.enableAllocationCallstacks = enableCallstacks;
186
190
  StopProfilingAfterDelay(logPath, fileName, durationSecs, profileInitiator);
187
191
  }
188
192
 
189
193
  private async void StopProfilingAfterDelay(string logPath, string fileName, float durationSecs, [CanBeNull] NetworkConnectionToClient profileInitiator) {
190
194
  await Task.Delay((int)(durationSecs * 1000));
191
195
  Profiler.enabled = false;
196
+ Profiler.enableAllocationCallstacks = false;
192
197
  var info = new FileInfo(logPath);
193
198
 
194
199
  Debug.Log($"Profiling completed. Retrieving upload URL...");
@@ -61,6 +61,9 @@ public class AirshipComponent : MonoBehaviour {
61
61
  internal static bool UsePostCompileReconciliation { get; set; } = true;
62
62
  private const bool ElevateToProtectedWithinCoreScene = true;
63
63
 
64
+ private static readonly List<GCHandle> InitGcHandles = new();
65
+ private static readonly List<IntPtr> InitStringPtrs = new();
66
+
64
67
  public static LuauScript.AwakeData QueuedAwakeData = null;
65
68
  public static readonly Dictionary<int, string> ComponentIdToScriptName = new();
66
69
 
@@ -110,6 +113,8 @@ public class AirshipComponent : MonoBehaviour {
110
113
  _validatedSceneInGameConfig = false;
111
114
  QueuedAwakeData = null;
112
115
  ComponentIdToScriptName.Clear();
116
+ InitGcHandles.Clear();
117
+ InitStringPtrs.Clear();
113
118
  }
114
119
 
115
120
  public static AirshipComponent Create(GameObject go, string scriptPath, LuauContext context) {
@@ -226,16 +231,17 @@ public class AirshipComponent : MonoBehaviour {
226
231
 
227
232
  InitAirshipComponent();
228
233
  }
229
-
230
- private void InitAirshipComponent() {
231
- InitializeAirshipReference();
232
234
 
235
+ private unsafe void InitAirshipComponent() {
236
+ InitializeAirshipReference();
237
+
233
238
  // Ensure all AirshipComponent dependencies are ready first
234
239
  foreach (var dependency in GetDependencies()) {
235
240
  dependency.Init();
236
241
  }
237
242
 
238
- var properties = new List<LuauMetadataProperty>(metadata.properties);
243
+ var properties = metadata.properties;
244
+ var propertiesCopied = false;
239
245
 
240
246
  // Ensure allowed objects
241
247
  for (var i = metadata.properties.Count - 1; i >= 0; i--) {
@@ -245,6 +251,11 @@ public class AirshipComponent : MonoBehaviour {
245
251
  case "object": {
246
252
  if (!ReflectionList.IsAllowedFromString(property.objectType, context)) {
247
253
  Debug.LogError($"[Airship] Skipping AirshipBehaviour property \"{property.name}\": Type \"{property.objectType}\" is not allowed");
254
+ if (!propertiesCopied) {
255
+ // As an optimization, we use the original metadata.properties list until we need to modify it at all, such as here:
256
+ propertiesCopied = true;
257
+ properties = new List<LuauMetadataProperty>(metadata.properties);
258
+ }
248
259
  properties.RemoveAt(i);
249
260
  }
250
261
 
@@ -253,16 +264,27 @@ public class AirshipComponent : MonoBehaviour {
253
264
  }
254
265
  }
255
266
 
256
- var propertyDtos = new LuauMetadataPropertyMarshalDto[properties.Count];
257
- var gcHandles = new List<GCHandle>();
258
- var stringPtrs = new List<IntPtr>();
267
+ var propertyDtos = properties.Count <= 1024 ?
268
+ stackalloc LuauMetadataPropertyMarshalDto[properties.Count] :
269
+ new LuauMetadataPropertyMarshalDto[properties.Count];
270
+
259
271
  for (var i = 0; i < properties.Count; i++) {
260
272
  var property = properties[i];
261
- property.AsStructDto(thread, gcHandles, stringPtrs, out var dto);
273
+ property.AsStructDto(thread, InitGcHandles, InitStringPtrs, out var dto);
262
274
  propertyDtos[i] = dto;
263
275
  }
264
276
 
265
277
  LuauPlugin.LuauInitializeAirshipComponent(context, thread, AirshipBehaviourRootV2.GetId(gameObject), _airshipComponentId, propertyDtos);
278
+
279
+ // Free handles:
280
+ foreach (var handle in InitGcHandles) {
281
+ handle.Free();
282
+ }
283
+ foreach (var strPtr in InitStringPtrs) {
284
+ Marshal.FreeCoTaskMem(strPtr);
285
+ }
286
+ InitGcHandles.Clear();
287
+ InitStringPtrs.Clear();
266
288
  }
267
289
 
268
290
  private void Start() {
@@ -470,6 +492,9 @@ public class AirshipComponent : MonoBehaviour {
470
492
  }
471
493
 
472
494
  private void OnValidate() {
495
+ if (Application.isPlaying) {
496
+ return;
497
+ }
473
498
  Validate();
474
499
  }
475
500
 
@@ -173,8 +173,8 @@ public partial class LuauCore : MonoBehaviour {
173
173
  requirePathCallback = requirePathCallback_holder,
174
174
  constructorCallback = constructorCallback_holder,
175
175
  toStringCallback = toStringCallback_holder,
176
- toggleProfilerCallback = toggleProfilerCallback_holder,
177
176
  isObjectDestroyedCallback = isObjectDestroyedCallback_holder,
177
+ getUnityObjectNameCallback = getUnityObjectNameCallback_holder,
178
178
  staticList = stringAddresses.AddrOfPinnedObject(),
179
179
  staticCount = stringCount,
180
180
  isServer = RunCore.IsServer() ? 1 : 0,