Skip to content

[Calendar update fixed] Reuse and dependency-inject Calendar#7

Merged
SCratORS merged 1 commit intoSCratORS:mainfrom
Doctoror:cache-calendar
Feb 4, 2024
Merged

[Calendar update fixed] Reuse and dependency-inject Calendar#7
SCratORS merged 1 commit intoSCratORS:mainfrom
Doctoror:cache-calendar

Conversation

@Doctoror
Copy link
Copy Markdown
Contributor

@Doctoror Doctoror commented Feb 4, 2024

This fixes #3

This is an amended commit that fixes time update issue.
Calendar will recompute time around every 40 seconds (every 800 frames assuming 20 fps).
Why 40 and not 60 seconds were chosen is to reduce possibility of being late by one minute for events like New Year.

@SCratORS
Copy link
Copy Markdown
Owner

SCratORS commented Feb 4, 2024

Does it even make sense to cache the calendar? Using it with every "update" does not entail any load.
I won't merge yet. I will leave this "pull request" open for the future.

@Doctoror
Copy link
Copy Markdown
Contributor Author

Doctoror commented Feb 4, 2024

New calendar instance was created for every frame, which is quite expensive, see
https://stackoverflow.com/questions/28704832/calendar-instances-are-particularly-expensive-to-create

Also, for every frame, Calendar instance was created twice, once for renderer, once for scene, meaning duplicate work for each frame and slightly different time between scene and renderer.

@SCratORS SCratORS merged commit 8f23027 into SCratORS:main Feb 4, 2024
@SCratORS
Copy link
Copy Markdown
Owner

SCratORS commented Feb 4, 2024

Convinced

@Doctoror Doctoror deleted the cache-calendar branch February 4, 2024 15:13
@SCratORS
Copy link
Copy Markdown
Owner

SCratORS commented Feb 4, 2024

if the phone is with the screen off, then all application activity stops. this means that the counter also stops working. when the background or animation changes when the screen is turned off, then after turning on the screen, those animations and backgrounds that were before the screen was turned off are played, in order for them to update, you must look at the screen for 800 "update" cycles, that is, 40 seconds, after which everything will change. But the user will not look to wait for the animation to change, he will say after 5 seconds that there is no animation change and will give a bad rating.

@Doctoror
Copy link
Copy Markdown
Contributor Author

Doctoror commented Feb 5, 2024

Yes, good point, I haven't noticed your comment earlier. Noticed it just now.

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.

Expensive operation Calendar.getInstance is called on every frame

2 participants