hismailbulut / Neoray

Simple and lightweight GUI client for Neovim
MIT License
148 stars 5 forks source link

Window vertical resize crash #22

Closed andis-sprinkis closed 3 years ago

andis-sprinkis commented 3 years ago

Please complete the following information:

Describe the bug Neoray crashes with error message when using mouse cursor resize to reduce window content size to the height of 1 line or 0. Sometimes it will succeed resizing to 0 height without crash, but will crash trying to increase the window height from that point.

Steps to reproduce Drag window border to reduce window height towards 0 height.

https://user-images.githubusercontent.com/52537705/134231132-d6ff8446-e07f-4af8-bbe9-045a248142a4.mp4

Your neoray config in init.vim (Only the part that concerns neoray!)

let s:fontname = 'CascadiaCodePL'
let s:fontsize = 13

execute 'set guifont=' . s:fontname . ':h' . s:fontsize

NeoraySet KeyZoomIn <C-ScrollWheelUp>
NeoraySet KeyZoomOut <C-ScrollWheelDown>

Crash log if available (may be generated by neoray after crash)

NEORAY v0.1.0 Release Crash Report 2021-09-21 19:02:54.0665805 +0000 UTC
Please open an issue in github with this file.
The program is crashed because of the following reasons:
[FATAL] [NEORAY] Assertion Failed: requested resize with zero parameter

goroutine dump:
goroutine 1 [running, locked to thread]:
main.createCrashReport({0xc0000120f0, 0x48})
    D:/a/neoray/neoray/src/logger.go:104 +0x330
main.logMessage(0xc330, 0xc0, {0xc0001379c8, 0x1, 0x8})
    D:/a/neoray/neoray/src/logger.go:168 +0x25a
main.assert(0x5, {0xc000137a48, 0x105df07, 0x7})
    D:/a/neoray/neoray/src/logger.go:184 +0x92
main.(*NvimProcess).requestResize(0x16d32c0, 0x0, 0x50)
    D:/a/neoray/neoray/src/nvimproc.go:548 +0x85
main.CreateWindow.func1(0xc000137ad0, 0x373, 0x1)
    D:/a/neoray/neoray/src/window.go:121 +0xa5
github.com/go-gl/glfw/v3.3/glfw.goFramebufferSizeCB(0x10546e6, 0x373, 0x1)
    C:/Users/runneradmin/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20210727001814-0db043d8d5be/window.go:219 +0x4b
github.com/go-gl/glfw/v3.3/glfw._Cfunc_glfwPollEvents()
    _cgo_gotypes.go:1517 +0x4e
github.com/go-gl/glfw/v3.3/glfw.PollEvents()
    C:/Users/runneradmin/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20210727001814-0db043d8d5be/window.go:964 +0x17
main.(*Editor).MainLoop(0x16d32c0)
    D:/a/neoray/neoray/src/editor.go:165 +0x38f
main.main()
    D:/a/neoray/neoray/src/main.go:71 +0x296

goroutine 38 [select]:
os/exec.(*Cmd).Start.func2()
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/os/exec/exec.go:449 +0x7b
created by os/exec.(*Cmd).Start
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/os/exec/exec.go:448 +0x8c5

goroutine 39 [syscall, locked to thread]:
syscall.Syscall6(0x7ffd6c432680, 0x5, 0x278, 0xc00049f000, 0x1000, 0xc0001f3ce4, 0x0, 0x0)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/runtime/syscall_windows.go:493 +0xfa
syscall.ReadFile(0x105dbb4, {0xc00049f000, 0x1000, 0x800000}, 0xc0001f3ce4, 0x0)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/syscall/zsyscall_windows.go:1024 +0xbe
syscall.Read(0xc00010ef00, {0xc00049f000, 0x100000000000020, 0x213f1e00008})
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/syscall/syscall_windows.go:380 +0x2e
internal/poll.(*FD).Read(0xc00010ef00, {0xc00049f000, 0x1000, 0x1000})
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/internal/poll/fd_windows.go:427 +0x1b4
os.(*File).read(...)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/os/file_posix.go:32
os.(*File).Read(0xc0001abb08, {0xc00049f000, 0xc0001f3e18, 0x105df07})
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/os/file.go:119 +0x5e
bufio.(*Reader).fill(0xc0004a4000)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/bufio/bufio.go:101 +0x103
bufio.(*Reader).ReadByte(0xc0004a4000)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/bufio/bufio.go:253 +0x2c
github.com/neovim/go-client/msgpack.(*Decoder).Unpack(0xc0004a2050)
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/msgpack/unpack.go:164 +0x3d
github.com/neovim/go-client/msgpack/rpc.(*Endpoint).Serve(0xc00001c0d0)
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/msgpack/rpc/rpc.go:195 +0x136
github.com/neovim/go-client/nvim.(*Nvim).Serve(0x0)
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/nvim/nvim.go:53 +0x90
github.com/neovim/go-client/nvim.(*Nvim).startServe.func1()
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/nvim/nvim.go:59 +0x25
created by github.com/neovim/go-client/nvim.(*Nvim).startServe
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/nvim/nvim.go:58 +0x8f

goroutine 11 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc0001e6c50, 0x39)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/runtime/sema.go:513 +0x146
sync.(*Cond).Wait(0x14f10e0)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/sync/cond.go:56 +0x8c
github.com/neovim/go-client/msgpack/rpc.(*Endpoint).dequeueNotifications(0xc00001c0d0)
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/msgpack/rpc/rpc.go:659 +0x5e
github.com/neovim/go-client/msgpack/rpc.(*Endpoint).runNotifications(0xc00001c0d0)
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/msgpack/rpc/rpc.go:671 +0x29
created by github.com/neovim/go-client/msgpack/rpc.(*Endpoint).Serve
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/msgpack/rpc/rpc.go:192 +0x125

goroutine 12 [semacquire]:
sync.runtime_SemacquireMutex(0x0, 0x0, 0x0)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/runtime/sema.go:71 +0x25
sync.(*Mutex).lockSlow(0xc0002c00b8)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/sync/mutex.go:138 +0x165
sync.(*Mutex).Lock(...)
    C:/hostedtoolcache/windows/go/1.17.1/x64/src/sync/mutex.go:81
github.com/neovim/go-client/nvim.(*Nvim).Serve(0x1183280)
    C:/Users/runneradmin/go/pkg/mod/github.com/neovim/go-client@v1.1.7/nvim/nvim.go:51 +0x58
main.(*NvimProcess).startUI.func2()
    D:/a/neoray/neoray/src/nvimproc.go:203 +0x25
created by main.(*NvimProcess).startUI
    D:/a/neoray/neoray/src/nvimproc.go:202 +0x3b4

Debug output (you can generate starting neoray with --verbose option)


NEORAY v0.1.0 Release LOG 2021-09-21 19:03:38.0066273 +0000 UTC
[DEBUG] [NVIM] Neovim started with command: nvim --embed
[TRACE] [NVIM] Neovim version 0.5.0
[TRACE] [NEORAY] Glfw version: 3.3.4 Win32 WGL EGL OSMesa MinGW
[DEBUG] [NEORAY] Monitor count: 1 Selected monitor: Generic PnP Monitor
[DEBUG] [NEORAY] Video mode &{Width:1440 Height:2560 RedBits:8 GreenBits:8 BlueBits:8 RefreshRate:60}
[DEBUG] [NEORAY] Glfw window created with size 883 662
[DEBUG] [NEORAY] Monitor diagonal: 23.80 pdpi: 136.29 ldpi: 106.00
[DEBUG] [NEORAY] Using logical dpi.
[DEBUG] [NEORAY] Input callbacks are initialized.
[DEBUG] [RENDERER] Initializing opengl.
[TRACE] [RENDERER] Opengl Version: 3.3.148202 Core Profile Forward-Compatible Context 21.3.1 27.20.15003.1004
[DEBUG] [RENDERER] Vendor: ATI Technologies Inc.
[DEBUG] [RENDERER] Renderer: Radeon RX 5500 XT
[DEBUG] [RENDERER] GLSL: 4.60
[DEBUG] [NEORAY] Loading default font.
[DEBUG] [NEORAY] Default font loaded.
[DEBUG] [NVIM] Attached to neovim as an ui client.
[DEBUG] [NEORAY] Requesting deprecated options.
[DEBUG] [NEORAY] Checking user options.
[DEBUG] [NVIM] Option KeyZoomIn is <C-ScrollWheelUp>
[DEBUG] [NVIM] Option KeyZoomOut is <C-ScrollWheelDown>
[DEBUG] [NEORAY] Window is now visible.
[TRACE] [PERFORMANCE] Start time: 594.4498ms
[DEBUG] [NEORAY] Loading font CascadiaCodePL with size 13
[TRACE] [NEORAY] Regular: CascadiaCodePL.ttf
[WARNING] [NEORAY] Font has no bold italic face.
[WARNING] [NEORAY] Font has no italic face.
[WARNING] [NEORAY] Font has no bold face.
[FATAL] [NEORAY] Assertion Failed: requested resize with zero parameter
andis-sprinkis commented 3 years ago

0.1.1 - can't make window smaller than 8 rows now, but at least it doesn't crash anymore :)

hismailbulut commented 3 years ago

I fixed the crash then I thought about it and realized that allowing to users to make window zero size is unnecessary. I hope no one is using window under ~200 pixel.

andis-sprinkis commented 3 years ago

In tiling window manager scenarios it's possible to end up with window lazily squashed to a couple of lines (<200px), and most text input and plugin TUI (e.g. vim-fugitive) windows in vim happen to be mostly usable even if it's 1 or 2 lines, so I'd prefer that limit to be as low as possible.

This is how my vim windows and buffers end up from time to time, and it's still usable to me :D VirtualBoxVM_Wt1jwDltai

andis-sprinkis commented 3 years ago

That being said, it looks like RESIZE mode of i3wm can ignore the limit on 0.1.1. VirtualBoxVM_HZ85EqLimd .

hismailbulut commented 3 years ago

If you or anyone don't like this limit we can simply remove it cause we fixed the actual issue. But as you said the window managers can ignore the limit it's safe to keep it because 0 size window is not looks good and may dissapear from monitor. Also we may limit minimum size as cell size (not pixel) like 2 rows and 16 columns.

andis-sprinkis commented 3 years ago

Personally I'm OK with the limit now that I have checked that tiling window managers on Linux can and most likely will ignore it. With ordinary floating windows it doesn't bother me at all.