Skip to content

Commit 5440510

Browse files
committed
Merge branch 'master' into 2021.3-urp
# Conflicts: # Packages/manifest.json # Packages/packages-lock.json # ProjectSettings/ProjectVersion.txt
2 parents 55d58cf + 3d2c3c8 commit 5440510

File tree

10 files changed

+213
-70
lines changed

10 files changed

+213
-70
lines changed

.github/templates/upgrade-unity-pr-body.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
### Built version demos
66

77
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-webgl2
8-
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-webgl1
8+
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-webgl2-debug
9+
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-minsize-webgl2
910

1011
### Other links
1112

.github/workflows/release.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,24 @@ jobs:
7373
if: ${{ github.ref == 'refs/heads/master' || needs.variables.outputs.TAG != needs.variables.outputs.UNITY_VERSION }}
7474
needs: [ variables ]
7575
runs-on: ubuntu-latest
76-
strategy:
77-
fail-fast: false
7876
steps:
7977
- uses: actions/checkout@v4
8078
with:
8179
fetch-depth: 0
8280
lfs: true
8381

82+
# Avoid running into space issues for github runners - Docker images can take up quite some space
83+
- name: Free Disk Space
84+
run: |
85+
echo "Disk space before cleanup:"
86+
df -h
87+
sudo rm -rf /usr/share/dotnet
88+
sudo rm -rf /opt/ghc
89+
sudo rm -rf /usr/local/share/boost
90+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
91+
echo "Disk space after cleanup:"
92+
df -h
93+
8494
# Unity 2020 cache is not compatible with older versions
8595
- name: Unity Library Cache 2020 or higher
8696
if: ${{ !startsWith(needs.variables.outputs.UNITY_VERSION, '201') }}
@@ -111,6 +121,17 @@ jobs:
111121
versioning: None
112122
buildName: ${{ needs.variables.outputs.BUILD_NAME }}
113123

124+
- name: Check Disk Space After Build
125+
run: |
126+
echo "Disk space after build:"
127+
df -h
128+
AVAILABLE=$(df / | tail -1 | awk '{print $4}')
129+
AVAILABLE_GB=$(echo $AVAILABLE | sed 's/G//')
130+
echo "Available space: ${AVAILABLE_GB}GB"
131+
if (( $(echo "$AVAILABLE_GB < 1" | bc -l) )); then
132+
echo "::warning::Low disk space! Less than 1GB remaining."
133+
fi
134+
114135
- uses: actions/upload-artifact@v4
115136
with:
116137
name: ${{ needs.variables.outputs.BUILD_NAME }}

.github/workflows/upgrade-unity.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ jobs:
3434
upgrade-unity-version:
3535
name: Upgrade Unity version and packages to ${{ inputs.unityVersion }}
3636
runs-on: ubuntu-latest
37-
strategy:
38-
fail-fast: false
3937
steps:
4038
- name: Log input parameter
4139
run: |
@@ -75,6 +73,18 @@ jobs:
7573
env:
7674
GIT_USER: ${{ github.actor }}
7775

76+
# Avoid running into space issues for github runners - Docker images can take up quite some space
77+
- name: Free Disk Space
78+
run: |
79+
echo "Disk space before cleanup:"
80+
df -h
81+
sudo rm -rf /usr/share/dotnet
82+
sudo rm -rf /opt/ghc
83+
sudo rm -rf /usr/local/share/boost
84+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
85+
echo "Disk space after cleanup:"
86+
df -h
87+
7888
# Make sure the branch has the latest master changes in
7989
- name: Merge master into current branch
8090
if: ${{ inputs.mergeMaster }}
@@ -149,6 +159,18 @@ jobs:
149159
allowDirtyBuild: true
150160
manualExit: true
151161

162+
- name: Check Disk Space After Build
163+
if: ${{ !inputs.tagsOnly }}
164+
run: |
165+
echo "Disk space after build:"
166+
df -h
167+
AVAILABLE=$(df / | tail -1 | awk '{print $4}')
168+
AVAILABLE_GB=$(echo $AVAILABLE | sed 's/G//')
169+
echo "Available space: ${AVAILABLE_GB}GB"
170+
if (( $(echo "$AVAILABLE_GB < 1" | bc -l) )); then
171+
echo "::warning::Low disk space! Less than 1GB remaining."
172+
fi
173+
152174
- name: Delete build folder with elevated rights
153175
if: ${{ !inputs.tagsOnly }}
154176
run: sudo rm -rf ./build

Assets/Plugins/WebGL/WebBridge/CommonCommands.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ public void LogMemory()
6666
WebToolPlugins.LogMemory();
6767
}
6868

69+
/// <summary>
70+
/// Logs the rough device memory capped between 0.25 and 8 GB
71+
/// Browser Usage: <code>unityGame.SendMessage("WebGL","LogDeviceMemory");</code>
72+
/// </summary>
73+
[WebCommand(Description = "Logs the device memory")]
74+
[ContextMenu(nameof(LogDeviceMemory))]
75+
public void LogDeviceMemory()
76+
{
77+
float deviceMemoryInMb = WebToolPlugins.GetDeviceMemory();
78+
if (deviceMemoryInMb > 0)
79+
{
80+
Debug.Log($"Device Memory: {deviceMemoryInMb} GB");
81+
}
82+
else
83+
{
84+
Debug.Log("Device Memory information is not available on this device or browser.");
85+
}
86+
}
87+
6988
/// <summary>
7089
/// Allocate memory to test memory usage and limits
7190
/// The memory will be stored in a list to prevent it from being garbage collected
@@ -192,7 +211,11 @@ public void LogInitializationTime()
192211
[WebCommand(Description = "Find GameObject by name and log its components")]
193212
public void FindGameObjectByName(string name)
194213
{
214+
#if UNITY_6000_0_OR_NEWER
215+
var gameObjects = GameObject.FindObjectsByType<GameObject>(FindObjectsSortMode.None).Where(go => go.name == name).ToArray();
216+
#else
195217
var gameObjects = GameObject.FindObjectsOfType<GameObject>().Where(go => go.name == name).ToArray();
218+
#endif
196219
if (gameObjects.Length == 0)
197220
{
198221
Debug.Log($"No GameObject found with the name: {name}");

Assets/Plugins/WebGL/WebBridge/WebBridge.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ private static void AddAllWebCommands()
7070
private static void SetGlobalVariables()
7171
{
7272
var graphicsDevice = SystemInfo.graphicsDeviceType;
73-
string webGraphics = string.Empty;
73+
string webGraphics;
7474
switch (graphicsDevice)
7575
{
76+
#if !UNITY_2023_1_OR_NEWER
7677
case GraphicsDeviceType.OpenGLES2:
7778
webGraphics = "WebGL 1";
7879
break;
80+
#endif
7981
case GraphicsDeviceType.OpenGLES3:
8082
webGraphics = "WebGL 2";
8183
break;

Assets/Plugins/WebGL/WebTools/WebToolPlugins.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public static class WebToolPlugins
3535
[DllImport("__Internal")]
3636
private static extern uint _GetTotalMemorySize();
3737
[DllImport("__Internal")]
38+
private static extern uint _GetDeviceMemorySize();
39+
[DllImport("__Internal")]
3840
private static extern bool _CopyToClipboard(string text);
3941
[DllImport("__Internal")]
4042
private static extern int _IsOnline();
@@ -191,6 +193,29 @@ public static float GetTotalMemorySize()
191193
#endif
192194
}
193195

196+
/// <summary>
197+
/// Get the device memory size in MB if supported by the browser
198+
/// Uses navigator.deviceMemory which is supported by chromium based browsers
199+
/// <see href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/deviceMemory"/>
200+
/// </summary>
201+
/// <returns>Size in MB or -1 if not supported</returns>
202+
public static float GetDeviceMemory()
203+
{
204+
#if UNITY_WEBGL && !UNITY_EDITOR
205+
var gb = _GetDeviceMemorySize();
206+
if (gb > 0)
207+
{
208+
return gb * 1024f; // convert to MB
209+
}
210+
return -1f;
211+
#elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
212+
Debug.Log($"{nameof(WebToolPlugins)}.{nameof(GetDeviceMemory)} called");
213+
return -1f;
214+
#else
215+
return -1f;
216+
#endif
217+
}
218+
194219
/// <summary>
195220
/// Get the managed memory size used by the application in MB
196221
/// </summary>

Assets/Plugins/WebGL/WebTools/WebToolPlugins.jslib

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ var WebGlPlugins =
9999
return -1;
100100
},
101101

102+
_GetDeviceMemorySize: function()
103+
{
104+
if(navigator.deviceMemory) {
105+
return navigator.deviceMemory;
106+
}
107+
return -1;
108+
},
109+
102110
_CopyToClipboard: function(text) {
103111
var str = UTF8ToString(text);
104112
navigator.clipboard.writeText(str)

0 commit comments

Comments
 (0)