Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching renderers multiple times causes graphical errors #236

Closed
palmski opened this issue Mar 27, 2014 · 3 comments
Closed

Switching renderers multiple times causes graphical errors #236

palmski opened this issue Mar 27, 2014 · 3 comments
Labels

Comments

@palmski
Copy link

palmski commented Mar 27, 2014

I have a graph display which needs to switch between a view on a page and a full-screen rendering. To this end I have two divs, one in the normal page flow and one for the full screen view. I am using the following code to switch between them:

JavaScript:

function showFullMap() {
    $('#mapContainer').hide();
    $('#mapContainerFull').show();
    switchToRenderer('sigma-container-full');
}

function hideFullMap() {
    $('#mapContainer').show();
    $('#mapContainerFull').hide();
    switchToRenderer('sigma-container');
}

function switchToRenderer(container) {
    var s = sigma.instances[0];
    for(i in s.renderers) {
            s.renderers[i].clear();
            s.killRenderer(i);
    }
    s.addRenderer(container);
    s.refresh();
}

HTML:

    <div id="mapContainer">
            <div class="sigma-parent" id="sigma-example-parent">
                    <div id="sigma-container" class="sigma-expand"></div>
            </div>
    </div>

    <div id="mapContainerFull">
            <div class="sigma-parent" id="sigma-example-parent">
                    <div id="sigma-container-full" class="sigma-expand"></div>
            </div>
    </div>

After three full-screen switches the map begins to render incorrectly, it appears to be zoomed in to 50% height and width. Each successive switch after this causes a further zoom. Is this a bug or a problem with my code? If the latter can you suggest a better method?

@apitts
Copy link
Contributor

apitts commented Mar 27, 2014

I have had exactly the same issue for the past few days and have been trying to figure out what is going on but have been unable to. I've tried killing the instance and starting a new one, I've tried killing the graph and I've tried killing the renderer and adding a new one....haven't been able to solve it yet.

@jacomyal
Copy link
Owner

jacomyal commented Apr 2, 2014

I just reproduced it, I already can see that the WebGL renderer is not properly killed and keeps its contexts. Thanks a lot for the report, I'm on it.

@jacomyal
Copy link
Owner

jacomyal commented Apr 2, 2014

OK. The killRenderer method actually destroys everything that links the renderer to the sigma instance, but the kill methods of the renderers do not exist yet, so the contexts and every references are still on, which explains the weird behaviour you met. I fix it as soon as I can.

@jacomyal jacomyal added snake and removed steak labels Apr 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants