Clean up debug rendering output

This commit is contained in:
Kovid Goyal 2024-03-26 13:06:08 +05:30
parent adf5917325
commit f7a7765ba2
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
9 changed files with 18 additions and 10 deletions

2
glfw/wl_window.c vendored
View file

@ -41,7 +41,7 @@
#include <fcntl.h>
#include <sys/mman.h>
#define debug(...) if (_glfw.hints.init.debugRendering) fprintf(stderr, __VA_ARGS__);
#define debug(...) if (_glfw.hints.init.debugRendering) { fprintf(stderr, "[%.3f] ", monotonic_t_to_s_double(monotonic())); fprintf(stderr, __VA_ARGS__); }
static GLFWLayerShellConfig layer_shell_config_for_next_window = {0};

View file

@ -819,9 +819,9 @@ no_render_frame_received_recently(OSWindow *w, monotonic_t now, monotonic_t max_
bool ans = now - w->last_render_frame_received_at > max_wait;
if (ans && global_state.debug_rendering) {
if (global_state.is_wayland) {
log_error("No render frame received in %.2f seconds", monotonic_t_to_s_double(max_wait));
fprintf(stderr, "[%f] No render frame received in %.2f seconds", monotonic_t_to_s_double(now), monotonic_t_to_s_double(max_wait));
} else {
log_error("No render frame received in %.2f seconds, re-requesting at: %f", monotonic_t_to_s_double(max_wait), monotonic_t_to_s_double(now));
fprintf(stderr, "[%f] No render frame received in %.2f seconds, re-requesting", monotonic_t_to_s_double(now), monotonic_t_to_s_double(max_wait));
}
}
return ans;

View file

@ -21,7 +21,7 @@
#import <Foundation/NSString.h>
#import <Foundation/NSDictionary.h>
#define debug(...) if (global_state.debug_rendering) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define debug(...) if (global_state.debug_font_fallback) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
typedef struct {
PyObject_HEAD

View file

@ -411,6 +411,11 @@ py_terminfo_data(PyObject *self UNUSED, PyObject *args UNUSED) {
return PyBytes_FromStringAndSize((const char*)terminfo_data, arraysz(terminfo_data));
}
static PyObject*
py_monotonic(PyObject *self UNUSED, PyObject *args UNUSED) {
return PyFloat_FromDouble(monotonic_t_to_s_double(monotonic()));
}
static PyMethodDef module_methods[] = {
METHODB(replace_c0_codes_except_nl_space_tab, METH_O),
{"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""},
@ -433,6 +438,7 @@ static PyMethodDef module_methods[] = {
{"shm_unlink", (PyCFunction)py_shm_unlink, METH_VARARGS, ""},
{"wrapped_kitten_names", (PyCFunction)wrapped_kittens, METH_NOARGS, ""},
{"terminfo_data", (PyCFunction)py_terminfo_data, METH_NOARGS, ""},
{"monotonic", (PyCFunction)py_monotonic, METH_NOARGS, ""},
{"find_in_memoryview", (PyCFunction)find_in_memoryview, METH_VARARGS, ""},
#ifdef __APPLE__
METHODB(user_cache_dir, METH_NOARGS),

View file

@ -1575,3 +1575,4 @@ def replace_c0_codes_except_nl_space_tab(text: Union[bytes, memoryview, bytearra
def terminfo_data() -> bytes:...
def wayland_compositor_pid() -> int:...
def window_fully_created(kitty_window_id: int) -> bool: ...
def monotonic() -> float: ...

View file

@ -15,7 +15,7 @@
#define MISSING_GLYPH (NUM_UNDERLINE_STYLES + 2)
#define MAX_NUM_EXTRA_GLYPHS_PUA 4u
#define debug(...) if (global_state.debug_rendering) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define debug(...) if (global_state.debug_font_fallback) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
static PyObject *python_send_to_gpu_impl = NULL;
#define current_send_sprite_to_gpu(...) (python_send_to_gpu_impl ? python_send_to_gpu(__VA_ARGS__) : send_sprite_to_gpu(__VA_ARGS__))

View file

@ -60,7 +60,7 @@ gl_init(void) {
int gl_major = GLAD_VERSION_MAJOR(gl_version);
int gl_minor = GLAD_VERSION_MINOR(gl_version);
const char *gvs = (const char*)glGetString(GL_VERSION);
if (global_state.debug_rendering) printf("GL version string: '%s' Detected version: %d.%d\n", gvs, gl_major, gl_minor);
if (global_state.debug_rendering) printf("[%.3f] GL version string: '%s' Detected version: %d.%d\n", monotonic_t_to_s_double(monotonic()), gvs, gl_major, gl_minor);
if (gl_major < OPENGL_REQUIRED_VERSION_MAJOR || (gl_major == OPENGL_REQUIRED_VERSION_MAJOR && gl_minor < OPENGL_REQUIRED_VERSION_MINOR)) {
fatal("OpenGL version is %d.%d, version >= 3.3 required for kitty", gl_major, gl_minor);
}

View file

@ -2301,7 +2301,6 @@ shell_prompt_marking(Screen *self, char *buf) {
break;
}
}
if (global_state.debug_rendering) fprintf(stderr, "prompt_marking: x=%d y=%d op=%s\n", self->cursor->x, self->cursor->y, buf);
}
static bool

View file

@ -12,7 +12,7 @@
from functools import lru_cache, partial
from gettext import gettext as _
from itertools import chain
from time import monotonic, time_ns
from time import time_ns
from typing import (
TYPE_CHECKING,
Any,
@ -72,6 +72,7 @@
is_css_pointer_name_valid,
last_focused_os_window_id,
mark_os_window_dirty,
monotonic,
mouse_selection,
move_cursor_to_mouse_if_in_prompt,
pointer_name_to_css_name,
@ -843,9 +844,10 @@ def set_geometry(self, new_geometry: WindowGeometry) -> None:
self.child_is_launched = True
update_ime_position = True
if boss.args.debug_rendering:
print(f'Child launched {monotonic() - self.started_at:.2f} seconds after window creation')
now = monotonic()
print(f'[{now:.3f}] Child launched {now - self.started_at:.2f} seconds after window creation', file=sys.stderr)
if boss.args.debug_rendering and self.child_is_launched:
print(f'SIGWINCH sent to child in window: {self.id} with size: {current_pty_size}', file=sys.stderr)
print(f'[{monotonic():.3f}] SIGWINCH sent to child in window: {self.id} with size: {current_pty_size}', file=sys.stderr)
self.last_reported_pty_size = current_pty_size
else:
mark_os_window_dirty(self.os_window_id)