Glance in app??

I got this error in ERA:

Error Name: Illegal Access (out Of Bounds)
Occurrences: 1
First Occurrence: 2020-12-22
Last Occurrence: 2020-12-22
Devices:
fēnix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6: 13.10
App Versions: 2.8.2
Languages: eng
Backtrace:
GRouteLoaderApp.getGlanceView:77

It's occurring in getGlanceView() for an app (not a widget).

I didn't thing glances existed for apps (so, I'm confused as to why getGlanceView() is being called).

Anybody know what the problem is?

(:glance)
function getGlanceView()
{
if(WatchUi has :GlanceView)
{
return [ new MyGlanceView(), new MyGlanceViewDelegate() ]; // Line 77
}
return null;
}

It shouldn't matter but MyGlanceView/MyGlanceViewDelegate are defined as following (because there isn't any glances).

class MyGlanceView extends WatchUi.View
{
    function initialize()
    {
        View.initialize();    	         
    }
    
    function onUpdate(dc)
    {
    	if(dc instanceof Toybox.Graphics.Dc)
    	{
			dc.setColor(Graphics.COLOR_BLACK,Graphics.COLOR_BLACK);
			dc.clear();
			dc.setColor(Graphics.COLOR_GREEN,Graphics.COLOR_TRANSPARENT);
	
			dc.drawText(dc.getWidth()/2, 5, Graphics.FONT_TINY,WatchUi.loadResource(Rez.Strings.AppName), Graphics.TEXT_JUSTIFY_CENTER);
		}
    } 
}

class MyGlanceViewDelegate extends WatchUi.BehaviorDelegate
{
    function initialize()
    {
        BehaviorDelegate.initialize();
    }
}

  • This could be an early change for CIQ 4.0.  At the Oct Conference, with a 4.0 VM it was mentioned device apps will have glances and widgets go away.

    For now, I'd say you don't want to have getGlanceView in a device app.

  • Err. It's not supposed to work that way.

    My app and widget are basically the same program.

    There's no way of determining whether something is an app or widget. (I use a resource but that isn't accessible in the glance.)

    I suppose I can create a helper class that is different between the game and no glance excludes.

  • If you have different jungle file for the widget and device app, you could use that.  Or for now, just turn off the glance view in both.

    It's a bug in the vm the way it sounds, but the question is how long before it's fixed....  From the looks of your glance code, it just displays the name, which is the behavior if you don't have a glance view at all.

  • Turning off the glance view in the widget isn't an option. I added it because of failures I was getting. (It's been a while since I added it).

    The problem isn't with the view anyway.

  • The crash is in getGlanceView when it's returning the view and the delegate.  Why are you returning a delegate? There's really nothing you can do in a glance input wise.  It's all handled by the FW. (up/down/select)

  • It's technically asking for a view and delegate. 

    I wouldn't expect returning null would work if it is expecting something.

    Retuning null appears to to in the simulator but, as we see, that's not always reliable.

    ==================≠

    Serious problems:

    1- The back button on menus disappears on some (?) devices in the widget. I had to add my own (the X that is there instead wreaks havock with my widget).

    2- exit-to isn't working for some (?) real devices in widgets. It doesn't exit and you are required to do a hard reboot of the device.

    3- glance is supported for some (?) devices that don't support glances.

  • You don't return null for the delegate.  You return nothing:

    	(:glance)
    	function getGlanceView() {
            return [ new WUWGView() ];
        }	

    Just return the view.

    The sim may not allow glances on some devices, but the firmware might.  It has to do with which sdk and devices you are using.  For a time, the sim didn't support glances on a 945, but the current firmware did, for example.

  • The firmware doesn't seem to be working correctly.

    I was expecting my code to work if the firmware supported it or not (by using the "has").

    ===================

    I was returning null for the array (not returning a view).

    I would not have expected one could provide a view but no delegate.

    Return the view based on the glance class or a normal view?

  • There are actually a number of cases where you return a view with no delegate.  Watch faces and simple widgets, though with watch faces you can have a delegate, but it's only used when you exceed the power budget

  • Documented (hopefully).

    So, this would work in the app if I just return a view based on a normal view (and no delegate)?