Complete
over 4 years ago

When is it not ok to call WatchUi.requestUpdate();?

Hi,

This one is a new one on me!

I saw an ERA log from onSettingsChanged that crashed out on my DataField onSettingsChanged handerl:

    function onSettingsChanged() {
        if(view) {
            view.onSettingsChanged();
            WatchUi.requestUpdate(); // CRASHES HERE
        }
    }

There is nothing contentious that I can see in onSettingsChanged (except a slightly annoying Attention.playTone that I had decided to remove on account of it being annoying in any case) - just some maths that is null checked, valid and safe.

So:

1. Is there any time that it is either illegal or unwise to call WatchUi.requestUpdate()

2. How does one test for that?

Thanks,
G

  • HI Travis, Had another one today. Pretty much identical code - line 26 is the requestUpdate call.
    function onSettingsChanged() {
    	if(mView) {	
    		mView.onSettingsChanged();
    		WatchUi.requestUpdate(); // @ CRASH IS HERE @
    	}
    	
    }
    Will do a find and replace across all my DF projects and remove that line.
    Error Name: System Error
    Occurrences: 1
    First Occurrence: 2020-12-03
    Last Occurrence: 2020-12-03
    Devices:
        Edge® 520 Plus: 5.70
    App Versions: 0.0.37
    Languages: eng
    Backtrace:
        DataField_SingleDialBaseApp.onSettingsChanged:26
    Cheers, G
  • [quote userid="117737" url="~/developer/connect-iq/f/discussion/246510/when-is-it-not-ok-to-call-watchui-requestupdate/1171891"]If you are (or were) seeing a crash from a call to WatchUi.requestUpdate() could you elaborate on the use case so that I can file a bug report? From my reading of the above the request is happening in onSettingsChanged() for a data field app. Is that sufficient to reproduce the problem?[/quote] I saw the report a few months ago also in my watch face code (only in era reports though, I didn't see the watch face actually crash)
  • I can recall when this changed - it was a year or 2 back.  I checked the DF where I first saw it, hoping I had a date/ciq version where it came up, but no such luck.  I's just commented out with "no longer available in DFs"  I recall it was kind of an obscure error message.  It might have been only on devices and not the sim.
  • It’s a single ERA report, so can’t flesh it out much. What I can confirm: 1. This is a pretty basic DataField and onSettingsChanged in the app is as per OP 2. The onSettingsChanged in the DataField does a few simple calculations and also called (it was annoying, so it doesn’t any more) Attention to play tone, buzz or vibrate depending on what’s available.  That’s about it really...
  • I'm pretty sure it should be legal to call WatchUi.requestUpdate() at any time (provided the symbol is available). We have code that should cause the request to be ignored in the case of being called from a data field. If you are (or were) seeing a crash from a call to WatchUi.requestUpdate() could you elaborate on the use case so that I can file a bug report? From my reading of the above the request is happening in onSettingsChanged() for a data field app. Is that sufficient to reproduce the problem? Filed WERETECH-10096