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

HTML5 error when adding font #29

Open
SalavatR opened this issue Aug 16, 2023 · 12 comments
Open

HTML5 error when adding font #29

SalavatR opened this issue Aug 16, 2023 · 12 comments

Comments

@SalavatR
Copy link

SalavatR commented Aug 16, 2023

hi! after release on html5 platform, we got errors, can't reproduce local

"RuntimeError: abort(Assertion failed: font_cfg->FontData != 0L && font_cfg->FontDataSize > 0, at: upload/imgui/src/imgui/imgui_draw.cpp,1899,AddFont). Build with -s ASSERTIONS=1 for more info.","abort@:1:12355","___assert_fail@:1:19145"

@britzl
Copy link
Owner

britzl commented Aug 16, 2023

It looks like it is font related. Are you using a custom font and imgui.font_add_ttf_data()? If so, is the font available and loaded correctly?

@SalavatR
Copy link
Author

yes, it works like a charm on all available devices and browsers, but i got this error in sentry

@SalavatR
Copy link
Author

this error never happens if we run directly html page
our QA sometimes cought it only in iframe on platforms

@britzl
Copy link
Owner

britzl commented Apr 11, 2024

our QA sometimes cought it only in iframe on platforms

Interesting. How are you loading the font?

@SalavatR
Copy link
Author

	imgui.set_ini_filename()
	imgui.set_ini_filename("devtool.ini")
	-- dv.set_style()

	imgui.set_style_color(imgui.ImGuiCol_MenuBarBg, 1.0, 0.01, 0.02, 0.01)
	local w, h = window.get_size()

	local global_font_scale = 2.2
	local scale_all_sizes = 2.5
	if w > h then
		global_font_scale = global_font_scale * w / display_height
	else
		global_font_scale = global_font_scale * h / display_height
	end
	imgui.scale_all_sizes(scale_all_sizes)

	local regular_data, error = sys.load_resource("/assets/imgui_res/space_mono_regular.ttf")
	if sysutil.is_android() then
		imgui.set_global_font_scale(global_font_scale)
	elseif regular_data then
		imgui.font_add_ttf_data(regular_data, #regular_data, 12.0 * global_font_scale, 12.0 * global_font_scale)
	end

@britzl
Copy link
Owner

britzl commented Apr 12, 2024

imgui/src/imgui/imgui_draw.cpp,1899,AddFont

I should probably update to the latest version of DearImGUI. The version used in this extension is two years old. It might help.

One thing which you could do is to add some printf()'s in imgui_draw.cpp:1899 to check what exactly it is asserting on.

@britzl
Copy link
Owner

britzl commented Jun 2, 2024

@SalavatR would you mind trying with the latest version? It was updated to ImGui 1.89.9. And if it doesn't work then please provide a sample project that I can try.

@SalavatR
Copy link
Author

SalavatR commented Jul 22, 2024

Hello!
i found repro case on mac os

https://yandex.ru/games/app/183506

https://vk.com/app7952341

https://ok.ru/game/mergehotel

if i open many tabs very fast i got error:
image

But i got it only in iframes, can't get when open direct links from cnd
https://cdn.mergeitgame.com/html5/yg/index.html
https://cdn.mergeitgame.com/html5/vk/index.html
https://cdn.mergeitgame.com/html5/ok/index.html

@britzl britzl changed the title HTML5 error HTML5 error when adding font Jul 22, 2024
@britzl
Copy link
Owner

britzl commented Jul 22, 2024

if i open many tabs very fast i got error:

I can also reproduce this. I looked more closely at the code when the font is loaded from memory and there is a memory allocation that might fail. I've now added a check for this and a dmLogWarning(). Perhaps you could try the new version and see if the failed allocation was the reason?

https://github.com/britzl/extension-imgui/releases/tag/2.3.1

@SalavatR
Copy link
Author

image still same error

@britzl
Copy link
Owner

britzl commented Jul 22, 2024

That is not exactly the same error though. Initially it was IM_ASSERT(font_cfg->FontData != NULL && font_cfg->FontDataSize > 0); but now it is IM_ASSERT(font_cfg->SizePixels > 0.0f);

@britzl
Copy link
Owner

britzl commented Jul 22, 2024

What is the size you are passing to imgui.font_add_ttf_data() ?

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

No branches or pull requests

2 participants