[4.x] Godot flies out when I hide the window
Tested versions
Godot 4.1.3, Godot 4.2.1
System information
Godot v4.1.3.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated Radeon RX 560 Series (Advanced Micro Devices, Inc.; 31.0.14001.45012) - Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 Threads)
Issue description
When I click the "minimize" button in a running application, godot displays many errors in the console and crashes. In the example, I use this plugin, it’s unlikely that this is the problem, since this happens in all modes except “compatibility”
Errors in Forward+:
Errors in Mobile:
Steps to reproduce
- Run my example and run it in Forward+ or Mobile mode
- Minimize a window
- Wait about 15 seconds and you will see a huge number of errors
Minimal reproduction project (MRP)
Please try confirming that this happens without the plugin, that's an important thing to consider
Please try confirming that this happens without the plugin, that's an important thing to consider
It's almost impossible :( I repeated everything that was done in the example project, drawing the Viewport in sprite2d and texturerect, nothing happens, all the main rendering process is in GDCubismUserModel. If there were problems in compatibility mode, I would be sure that this is a plugin problem, but in compatibility mode everything works
That doesn't mean it isn't specific to the plugin though, so if it happens with the plugin and not otherwise it's very clearly related to the plugin, so the first step is to make sure the plugin isn't causing it, unless the plugin triggers a bug in the engine
That doesn't mean it isn't specific to the plugin though, so if it happens with the plugin and not otherwise it's very clearly related to the plugin, so the first step is to make sure the plugin isn't causing it, unless the plugin triggers a bug in the engine
I'll try to contact the plugin developer and ask him to chime in on this issue
I'd say to report it there instead first, if it doesn't happen at all without it
This is a matter under discussion, and it appears that there may be an issue on the side of the Godot Engine.
There might be a bug similar to the one I reported before at https://github.com/godotengine/godot/issues/81476.
The issue of increasing memory usage when minimizing the window can be reproduced by a script that explicitly sets a property (transparent_bg) on an initialized SubViewport.
extends Node3D
const NODE_COUNT: int = 32
var ary_n: Array[Node3D]
var ary_v: Array[SubViewport]
func _ready():
for i in range(NODE_COUNT):
var n = Node3D.new()
self.ary_n.append(n)
var v = SubViewport.new()
self.ary_v.append(v)
n.add_child(v)
add_child(n)
func _process(_delta):
for n in self.ary_n:
for v in n.get_children():
n.remove_child(v)
remove_child(n)
var index = 0
for n in self.ary_n:
var v: SubViewport = ary_v[index]
v.transparent_bg = true
n.add_child(v)
add_child(n)
index += 1
This code does not render anything, but when the window is minimized, static memory starts to be used.
It is used up at an incredible speed, so it is recommended to restore from minimization immediately.
This behavior has been confirmed on the Windows and macOS versions of Godot Engine 4.1.2.
@AThousandShips
It appears that minimizing the window leads to additional issues.
When the window is minimized, dynamically generated ArrayMesh are not discarded, leading to a memory leak as they continue to accumulate in memory.
Although there is no verification code, it seems that a memory leak occurs only when the window is minimized if the following process is performed on a MeshInstance2D added to SubViewport:
Array ary;
ary.resize(Mesh::ARRAY_MAX);
ary[Mesh::ARRAY_VERTEX] = gen_vertex(...);
ary[Mesh::ARRAY_TEX_UV] = gen_uv(...);
ary[Mesh::ARRAY_INDEX] = gen_index(...);
Ref<ArrayMesh> ary_mesh;
ary_mesh.instantiate();
ary_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, ary);
...
node->set_mesh(ary_mesh)
This issue is different from the one reported above, but it is a bug that occurs around SubViewport, so I added it here first.
I have reported this issue along with reproducible code at the following link: Godot Engine Issue #90030
Since I have isolated the problem and simplified the code, I feel it would be okay to close this one.