Search code examples
autodesk-forgeautodesk-viewer

How to active "Autodesk.MemoryLimited" Extension in Forge Viewer?


I'm having trouble loading a Large Model in local environment forge viewer.

Already I had check Autodesk Forge Viewer Guide "Allocate Memory for Large Models"(https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/viewer_basics/memory-limit/)

and I apply "Autodesk.MemoryLimited" Extension in viewer config but anything isn't happened. Guide document say Developers and users can validate the feature is in action by verifying that the bottom-left loading bar displays in blue instead of green, but loading bar is not changed(still green).

also i load "Autodesk.Viewing.MemoryLimitedDebug" Extension.

Do you have an idea to activate "Autodesk.MemoryLimited" Extension?

Memory Manager


Solution

  • The documentation is missing one small piece of information unfortunately. When using the Autodesk.Viewing.MemoryLimited extension you have to configure the actual memory limit you want to impose, for example, like so:

    const config = {
        loaderExtensions: { svf: 'Autodesk.MemoryLimited' },
        memory: {
            limit: 1024
        }
    };
    const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'), config);
    

    Also, note that the memory-limited loading will only be enabled when your model is larger than the configured threshold. If you want to force the memory-limited loading even for smaller models, try this:

    const config = {
        loaderExtensions: { svf: 'Autodesk.MemoryLimited' },
        memory: {
            limit: 1024,
            debug: {
                force: true
            }
        }
    };
    const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'), config);
    

    Edit

    The memory.debug object can contain additional properties customizing the behavior of the memory-limited loading. Those are meant for internal use but you could experiment with them as well:

    options.debug = {
            // Increase the max page out size. On slow (mobile) devices the scene
            // traversal is a bottle neck and making this larger helps load more
            // pack files earlier in the load.
            maxPageOutSize: 195,                                // Max we will page out in one go
            pixelCullingEnable: this.options.onDemandLoading,   // Useful with on demand loading
            pixelCullingThreshold: avp.PIXEL_CULLING_THRESHOLD,
    
            occlusionThreshold: 1,
            occlusionTestThreshold: 1,
            startOcclusionTestingPackCount: 8,
            testPackfileCount: 4,
            useOcclusionInstancing: true,
            automaticRefresh: true,
            boxProxyMaxCount: 0, // show this many boxes during a render
            boxProxyMinScreen: 0.4 // if entire render batch is >= 1/10 of the screen in area
        };