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

Draw issue with focus in UI elements (Compatibility renderer) #74115

Closed
rm-code opened this issue Feb 28, 2023 · 19 comments · Fixed by #85778
Closed

Draw issue with focus in UI elements (Compatibility renderer) #74115

rm-code opened this issue Feb 28, 2023 · 19 comments · Fixed by #85778

Comments

@rm-code
Copy link

rm-code commented Feb 28, 2023

Godot version

4.0.rc6.mono.official

System information

macOS 12.0.1

Issue description

Just a minor visual issue.

When opening an empty directory the focus highlight is drawn incorrectly. It looks like the UI is drawing a smaller rectangle within the main rect:
Bildschirmfoto 2023-02-28 um 14 13 31

This behavior also changes when you hover over other items in the view, so I'm not sure if this a general issue with the focus highlighting or just an issue in the directory view:
Bildschirmfoto 2023-02-28 um 14 32 54

Steps to reproduce

  1. New Project
  2. Browse
  3. Create Folder
  4. Click or Tab to set focus on the empty directory view

Minimal reproduction project

N/A

@dalexeev
Copy link
Member

I confirm this. Note that the bug is reproduced not in all dialogs.

Project Manager - Scan:

Open Scene:

@rm-code rm-code changed the title Draw issue with focus in UI on empty directories Draw issue with focus in UI elements Mar 5, 2023
@rm-code
Copy link
Author

rm-code commented Mar 5, 2023

The issue isn't limited to the file dialogues. Here are examples of the issue on non-empty UI screens:

Bildschirmfoto 2023-03-05 um 14 18 26

Bildschirmfoto 2023-03-05 um 14 26 11

@Calinou
Copy link
Member

Calinou commented Mar 28, 2023

This is not a rendering issue, but an issue with the GUI system. This is the IME (input method editor) having its focus outline visible at all times.

@a690089735
Copy link

downloading the export template

When I was downloading the export template, I accidentally clicked on the bottom box and it started flashing. If I clicked a few more times, it would flash faster

_.mp4

@dardasaba6
Copy link

Also experiencing this in 4.1 RC1 on Linux Mint:
Screenshot from 2023-06-29 16-28-04
Screenshot from 2023-06-29 16-31-57
Screenshot from 2023-06-29 16-32-23

@dalexeev
Copy link
Member

dalexeev commented Jul 20, 2023

@dalexeev
Copy link
Member

As stated in #71213, the bug is reproducible with the Compatibility renderer. I confirm that the bug is reproducible in 4.1.1 and the current master in Compatibility mode.

@dalexeev dalexeev changed the title Draw issue with focus in UI elements Draw issue with focus in UI elements (Compatibility renderer) Aug 16, 2023
@Calinou Calinou pinned this issue Aug 16, 2023
@lawnjelly
Copy link
Member

lawnjelly commented Aug 16, 2023

An MRP would probably really help investigate this, if someone can get it to trigger in a simple project. Speaking from experience debugging the editor GUI in 3.x, there is a lot going on, so the first step is usually to simplify it down to the bare minimum draw items to create the bug. It probably just needs some GUI control.

It could be a problem in the GLES3 backend, or the GUI code (even if Vulkan is behaving ok).

EDIT:
Just to reiterate, this is a request for an MRP that isn't the editor. i.e. Identify the UI items in use, recreate them in a simple project and see if you can reproduce. This is usually possible (not necessarily always) because the editor is made with Godot UI items. This is usually the easiest way to track down UI rendering bugs.

@dalexeev

This comment was marked as resolved.

@WhalesState
Copy link
Contributor

WhalesState commented Aug 16, 2023

I have tried to add a breakpoint inside draw_rect and draw_stylebox functions in CanvasItem and RenderingServer equivalent functions with no luck on identifying where's the code that is responsible to focus the Editor's UI, also since there are no other's issue related to TreeItem then we can identify this as an Editor only issue, the issue Mostly happens with the calculation of the Control's position and size, and the appearance of another focus rect means that it was meant to focus both the Current Panel and the Current pressed UI element at same time. if it works with two focus rects in vulkan correctly then we need to use #ifdef to make opengl es 3.0 behave differently else if it only shows one focus rect in vulkan then we need to identify why the other rect is drawing again and to fix this issue.

@HolySkyMin
Copy link
Contributor

HolySkyMin commented Sep 1, 2023

Here is MRP of the problem, which is reproduced in-game.
MRP.zip

The problem seems to arise when ItemList and Tree (there may be more, but at least not Button and LineEdit) are inside non-main Window. As seen in video, focus graphic in main window is also being shown in another window. (You can even see that bugged graphic moves smoothly if you're lucky enough(?))

weird_window.mp4

@WhalesState
Copy link
Contributor

WhalesState commented Sep 2, 2023

Here is MRP of the problem, which is reproduced in-game. MRP.zip

The problem seems to arise when ItemList and Tree (there may be more, but at least not Button and LineEdit) are inside non-main Window. As seen in video, focus graphic in main window is also being shown in another window. (You can even see that bugged graphic moves smoothly if you're lucky enough(?))

weird_window.mp4

Tested this, it's only Tree which is causing this issue.

image

@WhalesState
Copy link
Contributor

WhalesState commented Sep 2, 2023

check this
image

after commenting the focus line in tree.cpp, it appears to be drawing an extra panel and it's not the tree bg panel, i will make a panel with a different color for each stylebox to see which one is causing the issue.

The extra panel is not related to this Tree Node but it's another Tree bg panel since it's using the Tree bg panel but not the current Tree node bg panel.

this one is overriding the bg panel of the Tree node.

Tree.mp4

this one is using a theme to define the default Tree bg panel.

image

@HolySkyMin
Copy link
Contributor

HolySkyMin commented Sep 2, 2023

Investigated this more and these are what I've found out:

  • This problem occurs at Tree, empty ItemList and empty RichTextLabel.

    • ItemList and RichTextLabel with contents doesn't seem to have problem.
    • Tree, however, behaves way more stranger. With contents, it draws another focus stylebox where ScrollBar was last visible when it gets resized.
  • The problem is that focus stylebox is being drawn twice, first one is 'proper' drawing while second one is 'wrong'.

    image

    When they are empty, for some reason, it seems that when drawing focus graphic they grab main window's focused control and draw another stylebox from its position. Sometimes even the main window control's position update is applied(it happens so rarely that I couldn't record it).

    But this is not 100% guaranteed: It can appear in different position with different corner.

    2023_09_02_16_14_14_369.mp4

    See the flickering? It's switching frame by frame between two states! (This happens randomly so I don't know why)

    2023_09_02_16_21_29_180.mp4

    And Tree behaves like this...

These all are being found in sub Window, but maybe it could arise even in main window when they can be resized.

Looking into the code, I found that only these controls call RenderingServer::canvas_item_add_clip_ignore() when drawing their focus stylebox. Maybe this could be reason?

@WhalesState
Copy link
Contributor

WhalesState commented Sep 2, 2023

Looking into the code, I found that only these controls call RenderingServer::canvas_item_add_clip_ignore() when drawing their focus stylebox. Maybe this could be reason?

I can say yes, and those lines are needed because the ScrollContainer will clip the focus stylebox, what we can do is adding a MarginContainer inside the ScrollContainer so we can have some margins to draw the focus stylebox to avoid using those lines or to define content margins inside ScrollContainer.

like this:
image

@HolySkyMin
Copy link
Contributor

HolySkyMin commented Sep 2, 2023

I can say yes, and those lines are needed because the ScrollContainer will clip the focus stylebox,

I agree. It definitely needs, and I couldn't find any logic mistakes in GUI side codes. Logically it's just adding CLIP_IGNORE command on and off before and after POLYGON command to the renderer(may be wrong considering my shallow knowledge about whole codes), and other renderers are doing this well.

So I think RenderingServer::canvas_item_add_clip_ignore() and related rendering code seems to be malfunctioning in this case. I hope someone else take a look into that because I don't have enough knowledge about rendering.

EDIT: Updated MRP.
MRPP.zip

@boruok
Copy link
Contributor

boruok commented Sep 2, 2023

could this happen because engine can't calculate right values from stylebox? stylebox class had some changes before they are separated into diff files.

@WhalesState
Copy link
Contributor

WhalesState commented Sep 2, 2023

So I think RenderingServer::canvas_item_add_clip_ignore() and related rendering code seems to be malfunctioning in this case. I hope someone else take a look into that because I don't have enough knowledge about rendering.

Maybe the first draw call of the Panel before applying it's Stylebox and position is polluting the other draw calls, if there's another way to clean the GL renderer before drawing again then it will be a good fix or we add custom content margins for ScrollContainer and we allow the users to change it freely.

or the GL stylebox drawing needs a fix because this doesn't happen in Vulkan.

@filipworksdev
Copy link

Hi everyone. I am on Windows 10 and integrated Iris Xe 96EU GPU. I use Compatibility OpenGL backend. I started seeing this happen after I added a Tree into the hud. To me it seems to happen when Tree overlaps another control. It seems to draw a border around the last overlappign control. Also strangely 3D rendering/Camera seems to affect this because the lines vanish when I point the camera in specific direction in game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment