Skip to content

Commit 9e03c3a

Browse files
committed
Change support newer variables from unity for memory information
1 parent e2bd823 commit 9e03c3a

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Assets/Plugins/WebGL/WebTools/WebToolPlugins.jslib

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,41 +88,53 @@ var WebGlPlugins =
8888

8989
_GetTotalMemorySize: function()
9090
{
91-
if(typeof TOTAL_MEMORY !== 'undefined') {
91+
if(typeof HEAP8 !== 'undefined') {
92+
return HEAP8.length;
93+
}
94+
if(typeof TOTAL_MEMORY !== 'undefined') { // Legacy support
9295
return TOTAL_MEMORY;
9396
}
9497

95-
console.warn("Problem with retrieving unity value. TOTAL_MEMORY: " + typeof TOTAL_MEMORY);
98+
console.warn("Problem with retrieving total memory size");
9699
return -1;
97100
},
98101

99102
_GetTotalStackSize: function()
100103
{
101-
if(typeof TOTAL_STACK !== 'undefined') {
104+
if(typeof Module !== 'undefined' && typeof Module.STACK_SIZE !== 'undefined') {
105+
return Module.STACK_SIZE;
106+
}
107+
if(typeof TOTAL_STACK !== 'undefined') { // Legacy support
102108
return TOTAL_STACK;
103109
}
104110

105-
console.warn("Problem with retrieving unity value. TOTAL_STACK: " + typeof TOTAL_STACK);
111+
console.warn("Problem with retrieving stack size");
106112
return -1;
107113
},
108114

109115
_GetStaticMemorySize: function()
110116
{
111-
if(typeof STATICTOP !== 'undefined' && typeof STATIC_BASE !== 'undefined') {
117+
if(typeof Module !== 'undefined' && typeof Module.staticAlloc !== 'undefined') {
118+
return Module.staticAlloc;
119+
}
120+
if(typeof STATICTOP !== 'undefined' && typeof STATIC_BASE !== 'undefined') { // Legacy support
112121
return STATICTOP - STATIC_BASE;
113122
}
114123

115-
console.warn("Problem with retrieving unity value. STATICTOP: " + typeof STATICTOP + ", STATIC_BASE: " + typeof STATIC_BASE);
124+
console.warn("Problem with retrieving static memory size");
116125
return -1;
117126
},
118127

119128
_GetDynamicMemorySize: function()
120129
{
121-
if(typeof HEAP32 !== 'undefined' && typeof DYNAMICTOP_PTR !== 'undefined' && typeof DYNAMIC_BASE !== 'undefined') {
130+
if(typeof Module !== 'undefined' && typeof Module.dynamicAlloc !== 'undefined') {
131+
return Module.dynamicAlloc;
132+
}
133+
if(typeof HEAP32 !== 'undefined' && typeof DYNAMICTOP_PTR !== 'undefined' && typeof DYNAMIC_BASE !== 'undefined') { // Legacy support
122134
return HEAP32[DYNAMICTOP_PTR >> 2] - DYNAMIC_BASE;
123135
}
124136

125-
console.warn("Problem with retrieving unity value. HEAP32: " + typeof HEAP32 + ", DYNAMICTOP_PTR: " + typeof DYNAMICTOP_PTR + ", DYNAMIC_BASE: " + typeof DYNAMIC_BASE);
137+
console.warn("Problem with retrieving dynamic memory size");
126138
return -1;
127139
}
128140
};

0 commit comments

Comments
 (0)