Forge viewer crashes after loading specific model

2019-08-19 07:24发布

问题:

I have been trying to use the forge viewer to load somewhat large model, but it seems like that the viewer crashes after few seconds (3 - 5) of usage. (with typical Aw snap! page).

I've had no trouble with other models, but this happens on this specific model on Windows 10, Chrome.

I've tested loading in OS X, but it seem to work although it is somewhat slow.

My current best guess is that this is happening due to memory overflow in Chrome, but this is not yet certain, because the viewer crashes before I try to log the heap usage.

Is there any option that I can use for efficient model loading? Also, is there a debug mode that allows memory tracking?

If you need the model urn, please let me know.

Thanks!

回答1:

To modify the memory environment for the viewer (like iPhone), change the options parameters with memory limit values found here:

(refer to Default Memory Management section) https://developer.autodesk.com/en/docs/viewer/v2/overview/changelog/2.17/

In particular, you can force memory management like this: var config3d = { memory: { limit: 400, // in MB debug: { force: true } } }; var viewer = new av.Viewer3D(container, config3d); viewer.loadModel( modelUrl, {}, onSuccess, onError );

For debugging memory, try the following:

var memInfo = viewer.getMemoryInfo(); console.log(memInfo.limit); // == 400 MB console.log(memInfo.effectiveLimit); // >= 400 MB console.log(memInfo.loaded);

Lastly, you can open the memory manager panel extension, from the Chrome debug console, with this command...

NOP_VIEWER.loadExtension("Autodesk.Viewing.MemoryManager")

Click on the memory-chip icon, to bring up the panel (see screenshot below)...

In the memory tab, you can see many parameters relating to paged memory in order to render and network-load many meshes (mesh packs (pf) zip, sort by closest or largest mesh AABB, ignore meshes that are too few pixels on the screen, etc).

Another quick way to activate the Viewer's low-memory mode, is to trick your desktop chrome browser into thinking it's a mobile device, by activating mobile debugging. You can use this to test out mobile related memory issues. Follow this guide: Chrome debug - Mobile mode

Hope this helps!