Bug 1430 - Background erase not disabled with AWT GLCanvas and NewtCanvasAWT
Summary: Background erase not disabled with AWT GLCanvas and NewtCanvasAWT
Status: RESOLVED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: awt (show other bugs)
Version: 2.6.0
Hardware: All all
: P4 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2023-03-09 16:27 CET by crougier
Modified: 2023-09-29 03:23 CEST (History)
0 users

See Also:
Type: DEFECT
SCM Refs:
2e46eb1bf06ef07801062122716aa99a6c871646
Workaround: TRUE


Attachments
JOGLQuad example (3.16 KB, text/plain)
2023-03-09 16:27 CET, crougier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description crougier 2023-03-09 16:27:07 CET
Created attachment 856 [details]
JOGLQuad example

As mentioned in the javadoc of com.jogamp.opengl.awt.GLCanvas class, GLCanvas tries to disable background erase for the AWT Canvas. This works well :
- on Windows with Java 11 and JOGL 2.3.2
but it does not work :
- on Windows with Java 11 and JOGL 2.4.0 (regression)
- on Ubuntu with Java 11 and JOGL 2.3.2 or 2.4.0
- on Windows and Ubuntu with Java 17 and JOGL 2.3.2 or 2.4.0

Tested on Windows 10 and Ubuntu 20.04 with OpenJDK 11.0.12+7 and OpenJDK 17.0.6+10.
It can be reproduced with the attached JOGLQuad example, the background flickers when canvas is resized.
Workaround: setting the "sun.awt.noerasebackground" property to true solves this issue in all cases.
Comment 2 Sven Gothel 2023-03-09 17:31:32 CET
Celine posted in
https://forum.jogamp.org/Resize-flickering-with-AWT-GLCanvas-and-JOGL-2-4-0-tp4042181p4042192.html

Not really...
With JOGL 2.3.2, the sun.awt.windows.WToolkit.disableBackgroundErase(Canvas) is called :

    @Override
    public void disableBackgroundErase(Canvas canvas) {
        WCanvasPeer peer = AWTAccessor.getComponentAccessor().getPeer(canvas);
        if (peer == null) {
            throw new IllegalStateException("Canvas must have a valid peer");
        }
        peer.disableBackgroundErase();
    }

With JOGL 2.4.0, the sun.awt.SunToolkit.disableBackgroundErase(Component component) is called :

    public void disableBackgroundErase(Component component) {
        disableBackgroundEraseImpl(component);
    }

    private void disableBackgroundEraseImpl(Component component) {
        AWTAccessor.getComponentAccessor().setBackgroundEraseDisabled(component, true);
    }

The regression on Windows platforms may be due to this change.
Comment 3 Sven Gothel 2023-09-29 03:23:10 CEST
Commit 2e46eb1bf06ef07801062122716aa99a6c871646:

Commit c5431f46b7bf64f109315ec78461859dd88f202a 
reduced the disableBackgroundErase(..) to SunToolkit's variation which doesn't work on Windows
as it does not act upon the java.awt.Canvas peer post addNotify().

This re-introduces the java.awt.Canvas method via class JAWTUtil.BackgroundEraseControl
and its called only after addNotify() on Windows and ASAP for everyone else.
Method also calles the SunTookit variation just to be sure.