jzy3d / jzy3d-api

A Java API for 3d and 2d charts
BSD 3-Clause "New" or "Revised" License
281 stars 145 forks source link

Rendering hangs on macOS (crashes on Ubuntu) after few thousands of calls to render() #289

Closed jzy3d closed 1 year ago

jzy3d commented 2 years ago

Problem

macOS hangs as follow Capture d’écran 2022-07-07 à 18 19 12

Ubuntu crashes and the stack trace indicates that the JOGL "legacy" TextRenderer is culprit.

Disabling the legacy text rendering on macOS prevents hanging.

Explanation

This is due to a memory leak in the recent usage of the "legacy" jogl TextRenderer (which has been introduced to allow text rotation on native charts).

Solutions

One of:

jzy3d commented 1 year ago

The problem actually arose here : after needing to re-initialize the GLCanvas, the text renderer lost its cache, hence the caching mecanism has been disabled because of a lacking cache invalidation.

Use the following classes

So another solution would be to trigger text invalidation when GLEvenListener.dispose() gets called.

jzy3d commented 1 year ago

Other outcome of the analysis : the JOGL MR related to TextRenderer (which has been extracted in a standalone project here) is working better but is not perfect