Skip to content

[Issue] Unnecessary window redraws #13

@maramadany

Description

@maramadany

Platform: Linux (Ubuntu 24.04)

CoreDeck seems to be constantly redrawing even when idle, which becomes very noticeable in software-rendered environments, one example of which is the virtual machine I used to test the program (notice the high CPU usage):

Image

Admittedly this is more of a nitpicky 'correctness' issue, most people won't be running Android emulators under conditions where this causes major problems.

me:~/CoreDeck/build$ libglx=$(ldconfig -p | awk '/libGLX.so.0/{print $NF;exit}')
me:~/CoreDeck/build$ pid=$(pidof CoreDeck)
me:~/CoreDeck/build$ sudo bpftrace -e "uprobe:$libglx:glXSwapBuffers /pid == $pid/ {@swaps = count(); } interval:s:5 {print(@swaps); exit(); }"
Attaching 2 probes...
@swaps: 244


@swaps: 244

for reference:

me:~/CoreDeck/build$ cat testredraw.c 
#include <GLFW/glfw3.h>
#include <unistd.h>

int main(void) {

	if (!glfwInit()) return 1;

	GLFWwindow *w = glfwCreateWindow(640,480,"idle test",NULL,NULL);

	glfwMakeContextCurrent(w);
	glfwSwapInterval(1);


	while(!glfwWindowShouldClose(w)) {
		glClearColor(0.1f,0.1f,0.1f,1.0f);
		glClear(GL_COLOR_BUFFER_BIT);
		glfwSwapBuffers(w);
		sleep(1);
		glfwWaitEvents();
	}

	glfwDestroyWindow(w);
	glfwTerminate();
	return 0;

}
me:~/CoreDeck/build$ gcc testredraw.c  -o testredraw -lglfw -lGL
me:~/CoreDeck/build$ ./testredraw

in a different terminal:

me:~/CoreDeck/build$ libglx=$(ldconfig -p | awk '/libGLX.so.0/{print $NF;exit}')
me:~/CoreDeck/build$ pid=$(pidof testredraw)
me:~/CoreDeck/build$ sudo bpftrace -e "uprobe:$libglx:glXSwapBuffers /pid == $pid/ {@swaps = count(); } interval:s:5 {print(@swaps); exit(); }"
Attaching 2 probes...
@swaps: 0


@swaps: 0

Rerunning the last command while immediately putting the testredraw window in focus yields:

me:~/CoreDeck/build$ sudo bpftrace -e "uprobe:$libglx:glXSwapBuffers /pid == $pid/ {@swaps = count(); } interval:s:5 {print(@swaps); exit(); }"
Attaching 2 probes...
@swaps: 5


@swaps: 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeature requestNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions