Dc glitches black sometimes, not in simulator

I stumbled into some glitch.

When onUpdate is called I check if any values changed (cacheValid = true). If not, I call onPartialUpdate and only redraw the area from the previous second hand position and draw a new seconds hand.

I set cacheValid to false onHide, onShow, when the minute changes or when values change.

This works great, all logic is passed and less computing time is used.

However sometimes, mainly after starting the watchface, the dc get's black instead of inheriting the context. You only see the redrawn area (the cached buffer bg stays intact) and the new seconds hand.

This does not happen in the simulator, however it happens on my F8 Solar as well as on my Venu 3 amoled display.

The strangest thing is that it doesn't seem to happen in the always active state, where onPartialUpdate is directly called by the system.

Any ideas where I need to search for a solution? 

  • It does not clear the screen if you don't, so it would encourage developers to not do this, what would be even worse than not drawing the complete screen but only the changed part.
    I am not talking about the group of devices that clear the screen, but about devices using the framework that would not.

    To be 100% clear, I am suggesting that I think the sim should clear the screen before onUpdate() in ALL cases, for ALL simulated devices.

    This would lead developers to draw the entire screen in onUpdate(), othewise their apps wouldn't work properly in the sim.

    Currently the situation is the opposite afaik the sim doesn't ever clear the screen before onUpdate().

  • It's not about wanting to believe or listening, I really appreciate your feedback for the max.

    It's about me always looking for new borders to cross also in the way I develop things.

    For now I think I'll let the users choose and add a setting for Stable energy plan, or Minimal less stable energy plan.

  • Yes, but what I try to say is it might be a mess on a real device and not on the simulator if the developer doesn't clear the screen when onUpdate is handled.

  • The system calls onPartialUpdate at the proper times.  You shouldn't call it from within your code.

    And the only time you can get by with only updating part of the screen is when the system calls onPartialUpdate.

    The system will stop calling onPartialUpdate if the 30ms limit (avg) is exceeded.

    Trying to decide if you only want to update part of the screen can also cause issues with things like notifcations.

  • With notifications or other data changes the whole screen is generated.

    I'll put the logic in a shared function instead of calling onPartialUpdate directly.

  • The general rule if you want to work correctly on all devices, is when onUpdate is called, you need to update the entire screen

  • The system knows what you should do, don't try to smart it out. It called onUpdate. Otherwise it would've called onPartialUpdate

  • It's not about outsmarting the system but about reusing the logic.

    I have made a new function that is called from onPartialUpdate as well as from onUpdate when there are no changes, for Amoled I removed the clipping around the seconds hand. Things are working great on both devices now and as a backup users can select Maximum stability versus Minimum power usage.

    There is nothing wrong with trying things out and explore fields outside of given boundaries, that's were development and change happens.

    Having that said. Did you know that after you drawn a buffered device context to the given device context, changes to the buffer are still forwarded to the given device context oh okay, I'll shut up now ;).

    Come on folks, think out of the box and make the best products possible!