needle-tools / usd-viewer

USD Web Viewer based on Autodesk's WASM USD bindings and a three.js Hydra render delegate
Other
59 stars 6 forks source link

fix: lower maximum memory #11

Closed beersandrew closed 7 months ago

beersandrew commented 7 months ago

Added some code to toggle the max memory asked for: cleaner view here:

function isMobileDevice(){
    return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); 
}

const MAX_MEMORY_MOBILE=1024*1024*1024;
const MAX_MEMORY_DESKTOP=4*1024*1024*1024;
const MAX_DEVICE_MEMORY=isMobileDevice()?MAX_MEMORY_MOBILE:MAX_MEMORY_DESKTOP;

wasmMemory=new WebAssembly.Memory({
    "initial":INITIAL_MEMORY/65536,
    "maximum":MAX_DEVICE_MEMORY/65536,
    "shared":true
})

note: this seems to still have a memory issue on page refresh, as in reloading the page seems to ask for more memory each time, until the mobile browser eventually denies the request