Why I'm having this warning, Too many active WebGL contexts. Oldest context will be lost.

In my application, I have ResliceCursourWidget (3 genericRenderWindows) + a genericRenderWindow to display 3 3D actors,
In this application the users may have many interactions with those renderWindows, (change the Reslice center, the colorWindow, colorLevel…)

Also I’m deleting actors / renderWindows to display others depending on what the user picks

Sometimes all work just fine, but sometimes I’m getting this Warning:

RenderWindow.js:248 WARNING: Too many active WebGL contexts. Oldest context will be lost.

and the the ResliceCursourWidget renderWindows stop displaying actors, and they become just white …

Hi,

My two cents: you reached your browser’s limit. Chromium, for instance, has a limit of 16 contexts if I’m not mistaken. Other browsers likely have limits in the same order of magnitude. So, I believe you have to design your application to make use of fewer contexts (one is ideal). BTW, why do you need so many contexts? Take a look at this: javascript - Allowing more WebGL contexts - Stack Overflow

best,

Paulo

1 Like

Hello Paulo,

Thank you so much for your answer, yes what you said looks convenient,
Sorry I didn’t specify it before,

In my application I have a X number of patients, each patient has 3 files (A brain-MRI.vti, a brain-segmentation.vtk and a face-surface.vtk)

The user can choose from the list of patients a patient to display, so I charge the N patient files and I delete what is previously rendered (N-1) in order to render the new actors, (I delete the actors, mappers, widget (ResliceCursorWidget) and the OpenGLRenderWindow and the GenericRenderWindow),

I don’t know if this the right way to do it,
[video-to-gif output image]

PS: in the 3D view I have:
PLANS VIEW: Plans actors + Sphere actor
CERVEAU VIEW: Polydata actor + Sphere actor
PEELING VIEW: 2 Poly data actors + Sphere actor

I believe you can achieve that using a single render window. Take a look at this: Four dipsplay Window

Thank you, but in the official ResliceCursorWidget example they have used 4 render windows, I don’t understand why they did that if it is not optimal.

4 is definitely less than 16 and if you were to reuse your 4 renderwindows you would not get into that issue.

To reuse my 4 renderWindows, what is the best approach?

  • To delete the render windows and the actors, mappers, interactors… and re-create them again.
  • Or to delete just actor, mapper and interactors… and keep using the same renderWindows?

Thank you for you answer

Just add/remove actor in those renderwindows. Keep the rest (renderwindow, renderer, interactor) the same.

1 Like

Thank you!

1 Like