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

Dynamic Font: each font size opens new file handle #36971

Closed
bitwes opened this issue Mar 10, 2020 · 0 comments · Fixed by #44117
Closed

Dynamic Font: each font size opens new file handle #36971

bitwes opened this issue Mar 10, 2020 · 0 comments · Fixed by #44117
Milestone

Comments

@bitwes
Copy link

bitwes commented Mar 10, 2020

Godot version:
3.2 stable

OS/device including version:
MacOS Catalina 10.15.3

Issue description:
When a label has a Dynamic Font and it is "local to scene" then each instance of the label with a unique font size will result in a new open file handle to the underlying font file. The file handle will remain open until the label is freed.

When dynamically resizing fonts to fit various scenarios you can exceed default OS file handle limits.
Especially if you are not careful in tests. Eventually your game will crash because you can't open up anymore files. Commonly this resulted in a Null instance coming back from a call to load which caused an error later when trying to use it. This took a while to track down.

ERROR: _load: Cannot open font file 'res://path_to_font.ttf'

Steps to reproduce:
The project below has the minimum steps. to reproduce, but. this is the gist of it:

extends Node2D

var FontScene = load('res://FontScene.tscn')

func _add_nodes(how_many):
	for i in range(how_many):
		var fs  = FontScene.instance()
		fs.get_node("WithFont").get_font("font").size = i
		add_child(fs)

func _ready():
	_add_nodes(50)

On mac/linux run the following to count the open file handles to the .ttf file.

➜  ~ lsof | grep godot | grep .ttf | wc -l
      49

In the above example there are 49. handles because the initial font size was 16. When it hits 16 in the loop it does not result in a new file handle. being opened.

Minimal reproduction project:
https://github.com/bitwes/GodotIssueDynamicFontFileHandles

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

Successfully merging a pull request may close this issue.

2 participants