Viewer.destroy() this._onViewReady is undefined

jtanz
Posts: 28
Joined: Mon Mar 27, 2017 11:24 pm

Viewer.destroy() this._onViewReady is undefined

Postby jtanz » Wed May 03, 2017 5:57 pm

Am I missing something in my config.json or need to call onViewReady?

'Cannot read property 'destroy' of undefined'

Code: Select all

FORGE.RenderManager.prototype.destroy = function()
{
    ...

    if (this._onViewReady !== null)
    {
        this._onViewReady.destroy();
        this._onViewReady = null;
    }

}

User avatar
rroux
ForgeJS Team
Posts: 139
Joined: Wed Oct 26, 2016 12:19 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby rroux » Wed May 03, 2017 7:11 pm

This is a known bug that has been been fixed in this pull request : https://github.com/gopro/forgejs/pull/6 ... ee5ba5ef3a

This fixed has been merged in the master branch, so if you pull the HEAD of master it should work properly.

Thanks for your report!
- Raphaël

jtanz
Posts: 28
Joined: Mon Mar 27, 2017 11:24 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby jtanz » Thu May 04, 2017 1:12 am

So I am trying to destroy the viewer then re-initialize it to load up a new config.json into it. But it seems after being destroyed it does not load up the default story scenes media correctly, I also tried viewer.story.loadScene(sceneId) and it still doesn't load the media.

The purpose is to re-use the container and load or re-load the viewer with different config.json files. Is this not the correct way of doing that?

I am using the latest code clone of the git repository.

User avatar
rroux
ForgeJS Team
Posts: 139
Joined: Wed Oct 26, 2016 12:19 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby rroux » Thu May 04, 2017 8:09 am

Hi jtanz,

It is possible that the destroy method do not behave as expected because it needs a lot of testing and it needs to be improved for sure!
I think it involves a lot of work and test to provide an efficient destroy methods that clean the memory and the dom perfectly.
So I can't guarantee you that destroy is fully functional. The task is in our improvement roadmap.

Have a nice day!
- Raphaël

jtanz
Posts: 28
Joined: Mon Mar 27, 2017 11:24 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby jtanz » Thu May 04, 2017 1:36 pm

Is there any type of work around or is it possible to take the viewer.story.scene and potentially add a new hotspot manually to the object then refresh the view to display the newest hotspot?

User avatar
rroux
ForgeJS Team
Posts: 139
Joined: Wed Oct 26, 2016 12:19 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby rroux » Thu May 04, 2017 1:47 pm

I never tried to add hotspots at runtime personally, but my first guess would be to use the viewer.hotspots.addConfig method and pass a hotspotConfig to it ?!
- Raphaël

jtanz
Posts: 28
Joined: Mon Mar 27, 2017 11:24 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby jtanz » Thu May 04, 2017 1:55 pm

I will try that out.

Is there a way to re-load the scene media or just the new hotspot media image? I basically want to press a button and insert a new hotspot with onClick actions on it directly onto the screen. Then hopefully when I load a different scene and come back it will load the new hotspot correctly with all the other hotspots through the normal processes.

jtanz
Posts: 28
Joined: Mon Mar 27, 2017 11:24 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby jtanz » Fri May 05, 2017 1:57 pm

So using code to add and update the hotspots does not seem to work. The only way I got it working is by changing the config.json values through code, loading a different scene, then loading the previous scene which now has updated values and displays the new hotspot correctly.

Reloading the current scene does not work because of all the code that checks to see if the scene.id or scene is the current scene. When I manually call the .unload() and .load() it looks exactly like what happens when I destroy the entire object and try to load it again. Somewhere in the code it decides not to load the media correctly.

My current work around is to modify the config.json, load a temporary empty scene, then load the scene I made changes to.

arhenc
Posts: 3
Joined: Mon Jun 19, 2017 4:50 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby arhenc » Mon Jun 19, 2017 5:20 pm

Hi, please help me! How to delete viewer?
example code:

Code: Select all

var viewer = new FORGE.Viewer("container", config);
viewer.destroy();

error:

Code: Select all

forge.min.js:18 Uncaught TypeError: Cannot read property 'stop' of null
    at r.g.destroy (forge.min.js:18)
    at <anonymous>:1:9

What am I doing wrong?

User avatar
rroux
ForgeJS Team
Posts: 139
Joined: Wed Oct 26, 2016 12:19 pm

Re: Viewer.destroy() this._onViewReady is undefined

Postby rroux » Tue Jun 20, 2017 8:34 am

Hello arhenc,

What am I doing wrong?


Nothing, this sounds like a bug. I'll make some tests.
The destroy method has not been tested for a while. It's quite difficult to make a perfect destroy because use cases are unlimited.
We fix every time we found something, so thanks for the report! I'll come back to you with a working destroy!

Have a nice day!
- Raphaël

Who is online

Users browsing this forum: No registered users and 2 guests