tidbyt / community

A publishing platform for apps developed by the Tidbyt community 🚀
Apache License 2.0
379 stars 643 forks source link

Production server .webp render not matching development pixlet renders. (mk. II) #1779

Closed Meandmybadself closed 11 months ago

Meandmybadself commented 1 year ago

Howdy.

Seeing an odd issue with my application, Progress Clock.

Expected Functionality As designed, it should render a red box indicating the amount of time that has passed in the day.

Actual Functionality Currently, between 7:00pm and 11:59am CST, the production application no longer renders the red box behind the time.

Three additional abnormalities When running the application in the local pixlet environment, the application renders as expected. pixlet serve progressclock.star

When rendering the .webp and pushing to the device, it renders as expected. pixlet render progressclock.star && pixlet push "$TIDBYT_DEVICE_ID" progressclock.webp

When viewing the thumbnail of the application in the Tidbyt mobile app, it does not render as expected.

Steps to recreate If you can get things running against a production service, you can set a mock time here: https://github.com/tidbyt/community/blob/main/apps/progressclock/progressclock.star#L25

Debugging Is there a way that doesn't involve Wireshark to get my hands on the rendered .webp coming out of the production application?

jmanske commented 11 months ago

It might have something to do with timezones:

    # Get the current time in the specified timezone
    now = time.now().in_location(timezone)

    # Get the current local time
    current_time = time.now()

The cached time now is what you display, but current_time is what you are using when you calculate duration:

    # Create a new time object representing the start of the day
    start_of_day = time.time(hour = 0, minute = 0, second = 0, year = current_time.year, month = current_time.month, day = current_time.day, location = timezone)

    # Calculate the duration between the current time and the start of the day
    duration = current_time - start_of_day

Since you say the problem is only happening during some specified time period, the issue feels very "timezone math"-related to me.

Edit: that is almost certainly the problem when I am checking it now later in the day.

A more straightforward implementation is to probably do something like this to get how many seconds have elapsed for the day:

now.hour * 3600 + now.minute * 60 + now.second
Meandmybadself commented 11 months ago

That was the issue. Thank you, @jmanske. IMG_7764