community icon indicating copy to clipboard operation
community copied to clipboard

Raspberry pi 3 model B high cpu usage

Open franciscogneto opened this issue 4 years ago • 5 comments

Software Versions

  • Python:3.9.2
  • OS: Raspberry Pi OS with desktop 32-bit
  • Kivy: 2.0.0
  • Kivy installation method: like the documentation

Describe the bug I have a raspberry pi 3 model B+, but when i start the kivy's paint example (https://kivy.org/doc/stable/tutorials/firstwidget.html), during the execution when i make circles and lines the CPU usage goes to 200% or more, and i have already enabled opengl

Expected behavior The CPU usage less than 100%

To Reproduce

from random import random
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.graphics import Color, Ellipse, Line


class MyPaintWidget(Widget):

    def on_touch_down(self, touch):
        color = (random(), 1, 1)
        with self.canvas:
            Color(*color, mode='hsv')
            d = 30.
            Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
            touch.ud['line'] = Line(points=(touch.x, touch.y))

    def on_touch_move(self, touch):
        touch.ud['line'].points += [touch.x, touch.y]


class MyPaintApp(App):

    def build(self):
        parent = Widget()
        self.painter = MyPaintWidget()
        clearbtn = Button(text='Clear')
        clearbtn.bind(on_release=self.clear_canvas)
        parent.add_widget(self.painter)
        parent.add_widget(clearbtn)
        return parent

    def clear_canvas(self, obj):
        self.painter.canvas.clear()


if __name__ == '__main__':
    MyPaintApp().run()

Code and Logs and screenshots image image

franciscogneto avatar Feb 22 '22 19:02 franciscogneto

Hi @franciscogneto did you seen #7805?

misl6 avatar Feb 22 '22 19:02 misl6

no, i will try... later i come with the response

franciscogneto avatar Feb 22 '22 19:02 franciscogneto

@misl6 still the same cpu usage...

franciscogneto avatar Feb 22 '22 20:02 franciscogneto

Image while i using the app paint_example_executing

franciscogneto avatar Feb 23 '22 12:02 franciscogneto

I resolved the problem, for someone how see this issue in the future, kivy it's not good in raspberry cause the events, effects and animations are too cost to raspberry pi 3 cpu (weak), so if you wanna work with shapes or video in raspberry pi 3 i recommend you to use C++. But if you're working with something simple (screens, show data, inputs, iot) just avoid animations like screen transitions ( use NoTransition ) and enable opengl

franciscogneto avatar Feb 23 '22 17:02 franciscogneto