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

Performance issue? #78

Open
MalpenZibo opened this issue Oct 18, 2024 · 9 comments
Open

Performance issue? #78

MalpenZibo opened this issue Oct 18, 2024 · 9 comments

Comments

@MalpenZibo
Copy link

I recently completed porting my application from the layer shell library used by the pop_os team to this project.

In the process, I noticed an increase in CPU usage, both in an idle state and especially in some circumstances. I know that I'm a bit too general and also I moved from Iced12 to Iced13 in the process so it could be a regression (even if it's a major one so it seems strange to me).

Anyway, I will try to find more details, in the meantime three major things that I noticed are:

Scrollable

The scrollable widget has major issues during scrolling (both with the mouse and trackpad). It's almost impossible to scroll and the scroll freezes on the top and after a while reach instantly the bottom, so it's not a smooth experience.
In this case, I notice a huge increase in CPU usage.
The "old" version goes from 0.0%/0.2% to 1.0% during the scroll. Now goes from 0.2%/0.4% to 3.8%.

Slider

In this case, the situation is similar. I notice more or less the same CPU usage increment. The experience is smooth but the value changes during the user interaction with values that are not what are currently selected. (it's difficult to explain).
The problem here could be caused by me. On the audio slider on_change I call my PulseAudio using an iced Task, after setting the audio the pulseaudio subscription sends a Message with the new audio value.
If the interaction is too slow could happen:

  • the slider has a 15 value
  • the user moves the slider causing an on_change(30) message,
  • I send the on_change to pulse audio,
  • the user continues its interaction causing an on_change(50)
  • the pulse audio subscription sends the message with the new audio value (30)
  • the slider value is updated to 30 from 50 causing the graphical glitch

In this case, I could handle better the interaction but before this issue didn't appear. Could be related to the iced update from 12 to 13, the performance issue, or both. The spike in CPU usage remains strange.

Moving the mouse

Moving the mouse over a button caused an increase in CPU usage from 0.2% to 2.2% before it was 0.1% to 0.6%. If I open a submenu (so another wayland layer shell) it's even more evident because I trigger the submenu closing when I click in a specific zone of the layer and the close event lags quite a bit. Sometimes, I have to click multiple times to close the submenu.

Conclusion

I know that's a lot of stuff. I have no hurry and I don't expect to see everything resolved. I'm here only to give you feedback on a "real-world example" in case you want something to work on.

I will try my best to find the root cause of these problems but for me, it's difficult because first I have to study the codebase 😅

@Decodetalkers
Copy link
Collaborator

Decodetalkers commented Oct 18, 2024

Sometimes, I have to click multiple times to close the submenu.

I already know this issue.. I think maybe it is because that time, the events are too many... I do not very know how to fix it..

@Decodetalkers
Copy link
Collaborator

Ok. seems I have fixed some problems...

@Decodetalkers Decodetalkers pinned this issue Oct 20, 2024
@Decodetalkers
Copy link
Collaborator

Decodetalkers commented Oct 21, 2024

One problem is here

https://github.com/waycrate/exwlshelleventloop/blob/master/layershellev/src/lib.rs#L2220-L2256

when you forword the iced event, it will try to send messages through channel, but the receiver here only accept new message once a time, this sucks all the actions, I think maybe you can try to move the logic to a new thread? I do not come out with better way to fix it

@Decodetalkers
Copy link
Collaborator

https://github.com/waycrate/exwlshelleventloop/pulls

will this fix the issue? at least it fix some of mime case

@MalpenZibo
Copy link
Author

I will try. Recently, the pop_os team synced their iced fork with the upstream one, so I was able to test my program with Iced 13 with their version.

Some performance degradation is also present there. In particular, moving the mouse over a button and some other things. The scroll problem and the slider problem are not present.

@Decodetalkers
Copy link
Collaborator

Decodetalkers commented Oct 22, 2024

I will try. Recently, the pop_os team synced their iced fork with the upstream one, so I was able to test my program with Iced 13 with their version.

Some performance degradation is also present there. In particular, moving the mouse over a button and some other things. The scroll problem and the slider problem are not present.

I find out what happened with scroll, lol, I will fix it

Now in v0.9.4-rc2 the problem about the event too slow is solved, now it is fast enough

and the scroll problem is solved too, now it is smooth enough!

@MalpenZibo
Copy link
Author

That's way way way better!
With that version both the slider and the scroll problem are gone.

It remains a high CPU usage with the mouse over a button but could be related to the iced 13 version because it's present also in the pop_os fork (maybe it's just a little bit less)

I think that this issue could be closed with these changes

@Decodetalkers
Copy link
Collaborator

Decodetalkers commented Oct 31, 2024

Seems the last one is not my problem... my plugin does nothing when hover on the button.. seems it will be better to submit an issue to iced...

I have seen your pr, I think you should upgrade to the newest version, it improves the performance again.

@MalpenZibo
Copy link
Author

I think the same, the issue it's more iced related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants