Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focused text entry consumes 40%-80% of CPU in my app #1946

Closed
ababo opened this issue Feb 12, 2021 · 12 comments
Closed

Focused text entry consumes 40%-80% of CPU in my app #1946

ababo opened this issue Feb 12, 2021 · 12 comments
Assignees
Labels
bug Something isn't working optimization Tickets that could help Fyne apps run faster

Comments

@ababo
Copy link

ababo commented Feb 12, 2021

Describe the bug:

I have several forms where text entries can take and lose focus. I noticed that when entry is focused (even without entering any text) the CPU consumption seriously increases.

Screenshots

Screenshot 2021-02-12 at 11 28 17

Screenshot 2021-02-12 at 11 28 48

To Reproduce:

Use any app that contains text entries.

Reproducing conditions:

Platform: OS X 11.1
Go version: go1.15.7 darwin/amd64
Fyne version: v2.0.0

Note: This problem is not reproduced with Fyne v1.4.1.

@ababo ababo added the bug Something isn't working label Feb 12, 2021
@Jacalz
Copy link
Member

Jacalz commented Feb 12, 2021

Can you please fill out that issue template when opening bug reports? I see that you have used it, but then removed all of the template. Please just use the template which contains the necessary information to diagnose the issues. Thanks for understanding 🙂

@ababo
Copy link
Author

ababo commented Feb 12, 2021

@Jacalz updated

@ababo ababo changed the title Focused (password) entry consumes 40%-80% of my CPU Focused text entry consumes 40%-80% of CPU in my app Feb 12, 2021
@Jacalz
Copy link
Member

Jacalz commented Feb 12, 2021

Thanks 🙂

@bebo-dot-dev
Copy link

I see this issue on Linux Mint x64 with fyne v2.0.3. CPU usage seems to be around 25% here and the application has to have focus / be topmost for CPU usage to spike.

@andydotxyz
Copy link
Member

Are you also using fyne_demo when you see the problem @bebo-dot-dev ?

@bebo-dot-dev
Copy link

Hi @andydotxyz I wasn't using the fyne_demo when I saw this, I was playing with my little proof of concept application

..but now that you mentioned it, yes I can see it with the fyne_demo application too and CPU usage does seem to be ~40% with fyne_demo

@andydotxyz
Copy link
Member

Looking into this further I think the issue is that the cursor pulses through every possible frame, so the entire UI is refreshing at 60 FPS. Because we're doing Go->C->OpenGL this is expensive even though we are not actually rendering any new textures.
There are probably 3 possible approaches:

  • minimise the cursor pulse (i.e. add pause between a faster fade in and then fade out, so we refresh 1/3 the time)
  • implement partial refresh so that we can move to draw only the areas that changed (allow partial texture refresh of CanvasObject #428)
  • Find optimisations in our draw pipeline for the situation where we are not actually refreshing much...

I don't think any of these are simple unfortunately so the short term solution may be #1813 ?

@bebo-dot-dev
Copy link

Thanks for taking a closer look. I've not profiled power usage on a mobile device but this could make using a fyne app on mobile unfeasible.

Either the first option of reducing cursor pulse or #1813 could be decent short term solutions.

@andydotxyz
Copy link
Member

Interestingly it seems to be less of a problem on mobile because, in general, there are fewer things on screen.
The CPU relates to the number of things visible behind the Entry rather than the CPU usage of pulsing itself.

That said it does need to be sorted, though not sure I would switch off animations by default until we know that they are prohibitive.

@dweymouth
Copy link
Contributor

Is there any reason not to disable cursor animations on desktop? As far as I'm aware, on pretty much all desktop OSes and toolkits, the cursor just blinks, it doesn't fade in and out. If the CPU load is already less of an issue on mobile, leaving the fading animation on mobile and removing it on desktop would both mitigate the performance issue and make Fyne match desktop conventions more closely.

@andydotxyz
Copy link
Member

Is there any reason not to disable cursor animations on desktop? As far as I'm aware, on pretty much all desktop OSes and toolkits, the cursor just blinks, it doesn't fade in and out. If the CPU load is already less of an issue on mobile, leaving the fading animation on mobile and removing it on desktop would both mitigate the performance issue and make Fyne match desktop conventions more closely.

I don't think they just blink on/off. At least not the more polished UIs. However we could reduce CPU usage through making it a short transition.
That said the latest develop should be magnitudes better as the rectangle is not CPU rendered any more.

@andydotxyz
Copy link
Member

This was resolved already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working optimization Tickets that could help Fyne apps run faster
Projects
None yet
Development

No branches or pull requests

5 participants