Invalid value on View.findDrawableById in onLayout

Hi guys,

I'm receiving invalid values from ERA for no logical reason. The watch face runs fine in the simulator and my own device and also in the majority of the devices and users but on a few occasion, I'm receiving an invalid value error.

It happens on View.findDrawableById("windDirection"), this in line 54 of onLayout.

In my latest release, it happens more than my release before while I haven't even touched that part of the code.

Does anyone have a clue?

Error Name: Invalid Value
Occurrences: 7
First Occurrence: 2021-04-15
Last Occurrence: 2021-04-16
Devices:
fēnix® 6X Pro / 6X Sapphire / 6X Pro Solar / tactix® Delta Sapphire / Delta Solar / Delta Solar - Ballistics Edition / quatix® 6X / 6X Solar / 6X Dual Power: 15.20, 16.10
fēnix® 6X Pro / 6X Sapphire / 6X Pro Solar / tactix® Delta Sapphire / Delta Solar / Delta Solar - Ballistics Edition / quatix® 6X / 6X Solar / 6X Dual Power: 15.30
Descentâ„¢ Mk2 / Descentâ„¢ Mk2i: 2.10
App Versions: 1.3.0
Languages: eng, spa
Backtrace:
SurfWatchFaceView.setUpdatedTimestamp:141
Rez.WatchFace:46
Rez.WatchFace:46
SurfWatchFaceView.onLayout:54

Error Name: Invalid Value
Occurrences: 18
First Occurrence: 2021-04-15
Last Occurrence: 2021-04-16
Devices:
fēnix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6: 15.20
fēnix® 6S Pro / 6S Sapphire / 6S Pro Solar / 6S Pro Dual Power: 15.20
fēnix® 5 Plus: 14.00
Forerunner® 945: 6.20
Forerunner® 945: 6.20
fēnix® 5X Plus: 14.00
Forerunner® 745: 4.20
Forerunner® 245 Music: 6.20
App Versions: 1.3.0
Languages: dut, eng, fre, spa
Backtrace:
SurfWatchFaceView.setUpdatedTimestamp:141
Rez.WatchFace:47
Rez.WatchFace:47
SurfWatchFaceView.onLayout:54

  • You need to post some code.  Is it actually the findDrawableById() call, or maybe the line after when you try to set the value?  With "windDirection", as you sure you have a valid value?

  • Thanks for your help! :)

    The funny thing is my Fenix 5 never shows this problem. Also over 95% of the users don't get the error.

    if you fill a non-existing id the function will return null.

    A snippet of the code below, nothing wrong as far as I can spot, otherwise it would have thrown an exception. I'm very puzzled... :S

    class SurfWatchFaceView extends WatchUi.WatchFace {
        .
        .
        .
        private var textScroller;
    
        // Load your resources here
        function onLayout(dc) {
            setLayout(Rez.Layouts.WatchFace(dc));
            
    	.
    	.
    	.
       	textScroller = View.findDrawableById("TextScroller");
        }
    
        .
        .
        .
    
        // Update the view
        function onUpdate(dc) {
    	.
    	.
    	.
            setUpdatedTimestamp(Application.getApp().getProperty(SurfWatchFaceApp.STORE_KEY_TIMESTAMP_UPDATED));
            
            // Call the parent onUpdate function to redraw the layout
            View.onUpdate(dc);
        }
    
        .
        .
        .
    
        private function setUpdatedTimestamp(timestampNumber) {	
        	textScroller.setUpdatedTimestamp(timestampNumber);
        }
    
        .
        .
        .
    }

    class TextScroller extends WatchUi.Drawable {
        .
        .
        .
        public function setUpdatedTimestamp(updatedTimestampNumber) {
        	if (updatedTimestampNumber != null && (updatedTimestampNumber instanceof Lang.Number || updatedTimestampNumber instanceof Lang.Long)) {
           		var dataTs = Gregorian.info(new Time.Moment(updatedTimestampNumber), Time.FORMAT_MEDIUM);
           		self.updatedTimeString = Lang.format("$1$ $2$ $3$ $4$:$5$:$6$", [dataTs.day, dataTs.month, dataTs.year, dataTs.hour.format("%02d"), dataTs.min.format("%02d"), dataTs.sec.format("%02d")]);
           	} else {
           		self.updatedTimeString = "";
           	}
        }
        .
        .
    }

  • Consider things like what happens if your getProperty() call returns a null, as can happen with the objectStore.

  • Thanks again for your reply!

    hmm yeah... I have already built-in protection for that. There is a null check in the setUpdatedTimestamp function. Also, the function checks if the input is of the type Number and Long.

    I also see that the Backtrace doesn't make sense.

    The onLayout doesn't call the setUpdateTimeoutTimestamp function in any way.

    SurfWatchFaceView.onLayout:54 is actually calling this:

    windDirectionLabel = View.findDrawableById("windDirection");

    Totally non-related to setUpdatedTimestamp.

    Further, I have noticed that Time.Moment can accept a string or a null in the constructor. No error or exception will occur. Moment.value() will just return whatever is given.

    However, I do see that Gregorian.info can give "invalid Value" error instead of an exception.

    But it should never happen, the function is protected with checks. Also, the backtrace doesn't lead to inside the setUpdatedTimestamp function.

  • Well... I think I have solved it. But the problem moved to another spot.

    I have solved it by changing the input value from Long to Number. Which was not a problem in 98% of cases/devices. Only on a few devices and maybe not even always.

    But the invalid value occurs on a different spot now where I simply set a string. This particular code never had a problem before, the code never changed in this particular spot.

    Garmin really blows my mind...

  • Simliar problem when load a resource.

    Error Name: Invalid Value
    Occurrences: 8
    First Occurrence: 2022-07-13
    Last Occurrence: 2022-07-16
    Devices:
    Forerunner® 255: 10.10
    fēnix® 6X Pro / 6X Sapphire / 6X Pro Solar / tactix® Delta Sapphire / Delta Solar / Delta Solar - Ballistics Edition / quatix® 6X / 6X Solar / 6X Dual Power: 20.60
    fēnix® 7 / quatix® 7: 8.37
    Forerunner® 255 Music: 10.10
    Forerunner® 955 / Solar: 11.12
    fēnix® 5 Plus: 17.10
    App Versions: 4.8
    Languages: chs
    Backtrace:
    ManjianghongView.getDayOfWeek:2464
    ManjianghongView.drawSolarDate:2479
    ManjianghongView.drawTriGrid:2237
    ManjianghongView.drawBottomHugeAreaData:2427
    ManjianghongView.onUpdateView:1241
    ManjianghongView.onUpdate:1026

    Garmin really blows my mind as well.