Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Fix DPI scale #1

Open
danilw opened this issue Sep 30, 2022 · 4 comments
Open

Fix DPI scale #1

danilw opened this issue Sep 30, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@danilw
Copy link
Owner

danilw commented Sep 30, 2022

Just to track the problem.

Problem:
This nanovg-vulkan-glfw-integration-demo crash/segfault on resize.
Happening only when C code of nonovg library builded with C++ code.
Happening at random - can be first resize or multiple resizes.

Debug:
valgrind show no memory leaks, and same as gdb when crash happening it point on:

Thread 1 "example-vk_glfw" received signal SIGSEGV, Segmentation fault.
vknvg_renderCreateTexture (uptr=0xd86e90, type=1, w=1024, h=512, imageFlags=0, data=0x0) at /home/danil/2021_vulkan_projects/not_clean/nanovg-vulkan-glfw-integration-demo/example/../src/nanovg_vk.h:1457

https://github.com/danilw/nanovg-vulkan-glfw-integration-demo/blob/main/src/nanovg_vk.h#L1457

Not Vulkan or driver bug:
Changing VK_PRESENT_MODE_IMMEDIATE_KHR to VK_PRESENT_MODE_FIFO_KHR - crash still happening.
Changing MAX_FRAMES_IN_FLIGHT to 1 or 10 - crash still happening.

But pressing hotkey 3 (keyboard number 3) or commenting https://github.com/danilw/nanovg-vulkan-glfw-integration-demo/blob/main/example/example_vulkan_glfw_integration.cpp#L1414 to 1435 (removing nanovg render from loop) - no crash.

Bug in the C-code of nanovg.
And it does look like "double free or corruption" bug - https://youtu.be/xVT1y0xWgww

I checked static variables, and lots of other stuff, still can not see the source of problem... will update when find problem.

@danilw danilw added the bug Something isn't working label Sep 30, 2022
@danilw
Copy link
Owner Author

danilw commented Oct 1, 2022

Crash happening only on winWidth change and look like because
float pxRatio = swapChainExtent.width / (float)winWidth; this line
...

@danilw
Copy link
Owner Author

danilw commented Oct 5, 2022

Look like it worst case scenario - problem in font rendering in nanovg source code.
Looking on it.

Edit - not worst case it simple malloc out of free space, should be simple to fix .... or no

@danilw
Copy link
Owner Author

danilw commented Oct 5, 2022

DPI scale NOT fixed
just fixed two mistakes, to not make it crash on normal DPI
d1efe73
2929395

@danilw
Copy link
Owner Author

danilw commented Oct 6, 2022

found commit where I did this change
danilw/nanovg_vulkan@3e2feb3

but I dont remember why and what for
(currently I have broken Vulkan render loop because texture allocation when pixel size not 1 (dpi scale), still looking for correct fix)

@danilw danilw changed the title Nanovg creating crash on resize when compiled with C++ code Fix DPI scale Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant