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

Clear render cache when software rendering #3632

Merged
merged 1 commit into from Feb 9, 2023

Conversation

elliot-aeroqual
Copy link
Contributor

Description:

Each time testcanvas.Refresh is called we tell the render cache that it can be cleaned.
This gives the render cache a chance to be cleared when using the test canvas for software rendering.
This should have no impact on most users.

There isn't an open issue for this but it is essentially the same as 2069

Checklist:

  • Lint and formatter run with no errors.
  • Tests all pass

@andydotxyz
Copy link
Member

Thanks for the contribution - but this is surely too fast? The refresh call here is not called once per paint but once per object - so this could be called hundreds of times per draw frame.
Calling that fast seems like a bad idea - what problem are you improving?

@coveralls
Copy link

coveralls commented Feb 6, 2023

Coverage Status

Coverage: 61.789% (+0.001%) from 61.787% when pulling 416c1b7 on aeroqual:clear-render-cache-in-testing into 4744d19 on fyne-io:develop.

@elliot-aeroqual
Copy link
Contributor Author

Thanks for the contribution - but this is surely too fast? The refresh call here is not called once per paint but once per object - so this could be called hundreds of times per draw frame. Calling that fast seems like a bad idea - what problem are you improving?

Yes it is called more than required but the cache.Clean returns early almost all of the time at least.
The other place I considered putting it was in testcanvas.Capture().

You might not remember but I discussed this with you briefly on Discord. The problem is that if you are using software rendering then the cache is never cleared. This becomes a problem if you use the List widget at least because the cache holds references to widgets (list items) that would otherwise be GC'd.

I considered making an exported function for clearing the cache instead but that also doesn't feel right.
Anyway I'm happy to have any other suggestions because I'm also not that fond of this change.

@elliot-aeroqual
Copy link
Contributor Author

Thanks for the contribution - but this is surely too fast? The refresh call here is not called once per paint but once per object - so this could be called hundreds of times per draw frame. Calling that fast seems like a bad idea - what problem are you improving?

Yes it is called more than required but the cache.Clean returns early almost all of the time at least. The other place I considered putting it was in testcanvas.Capture().

You might not remember but I discussed this with you briefly on Discord. The problem is that if you are using software rendering then the cache is never cleared. This becomes a problem if you use the List widget at least because the cache holds references to widgets (list items) that would otherwise be GC'd.

I considered making an exported function for clearing the cache instead but that also doesn't feel right. Anyway I'm happy to have any other suggestions because I'm also not that fond of this change.

I was thinking about this last night and I can't remember why I thought putting it in testcanvas.Capture() was a worse option so I'm thinking about moving it there now if that would be better @andydotxyz .

@andydotxyz
Copy link
Member

Thanks for this.
I'm still not sure - if you clear the cache before drawing every time then the cache is surely useless?
What problem is this PR solving?

@elliot-aeroqual
Copy link
Contributor Author

Thanks for this. I'm still not sure - if you clear the cache before drawing every time then the cache is surely useless? What problem is this PR solving?

The issue is 2069 which was addressed in the mobile and glfw drivers here. This is to try to address that same issue but for the software driver.

My understanding of the cache clearing is it is only removing items that haven't been used for > 1 minute so clearing it before drawing makes no difference if you are redrawing the same widgets continuously. But if you change the content on the canvas then after 1 minute the renderers for content that is no longer being drawn will be cleared.

@andydotxyz
Copy link
Member

Ah apologies you are quite right - I had mistaken it for a cache reset!

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@andydotxyz andydotxyz merged commit 1efc32d into fyne-io:develop Feb 9, 2023
@elliot-aeroqual
Copy link
Contributor Author

Thanks
👍
Thanks for Fyne

@elliot-aeroqual elliot-aeroqual deleted the clear-render-cache-in-testing branch February 9, 2023 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants