Is this a known thing that I can ignore? Circular dependency error that makes no sense.

Hi,

I have a single, lone ERA report saying "Error Name: Circular Dependency Error" triggered by a method call in onExitSleep of a watch face which... sounds bad... but I have reviewed the code in question and there is literally no way that it _can_ be a circular error... And, if there was, I would expect to have seen a deluge of similar errors as I'm pretty sure that onExitSleep will be called more than once in the weeks since the last update.

Is this likely a Garmin bug or should I dig a little deeper?

G

  • Dig deeper.  See the programmer's guide - https://developer.garmin.com/connect-iq/reference-guides/monkey-c-reference/#monkeyclanguagereference

    "weak references"

    A case where I've seen this is a reference to a call back where that callback in in another class.

  • Hmm. Thanks, Jim.

    I still can't see how that applies here, though. 

    My method has no callbacks or other references. This is the method that's called in onExitSleep:

    function updatePalette() {
    	// Set safety colours for AOD.
    	isAOD = kpay.lowPowerMode && requiresBurnInProtection;
    	AODColCorrection = isAOD ? bgCol : 0;
    	if(displayGraph) {
    		displayGraph.setPalette([graphFgCol^AODColCorrection,graphBgCol^AODColCorrection,graphMarkerCol^AODColCorrection, G.COLOR_TRANSPARENT]);
    	}
    }

    Everything referred to is a class member. They cannot be weak references as they have to exist on the class by definition.

    They might be _null_ if they were called at a weird time, but not circular.

  • It's not that you have weak references.  It's that you need to make some weak to avoid a circular reference.

  • There is a bug on some devices when you call function from onExitSleep. I've got different errors but had to handle it. It's look like onExitSleep is called when no full stack of members (there is for example array member but there is no elements - Symbol not find, or Invalid value error). I can't explain it thoroughly what is going on.

    But maybe not bug, maybe you can't call function/members_elements from onExitSleep.

    What does exactly mean "you need to make some weak to avoid a circular reference"?

  • See the link I posted for details about using weak()

  • In my case there is no error Circular Dependency, I don't have access to "this.member.member".

    The link describes any general rule, something happens between onEnterSleep an onExitSleep (on some devices).

    Flow in view:

    -initialise

    -onLayout

    -onShow() calls FuncX

    -FuncX <-------run well

    -onEnterSleep

    - ********** what system does here, clearing memory???

    -onExitSleep() calls FuncX

    -FuncX <-------error symbol not found or invalid value or Unhandled Exception, so workaround  on some devices

    -onDraw calls FuncX

    -FuncX <-------run well always

    in my case

    - app has view member - mV

    - view has drawable member - mD

    - mD has mX member and doesn't have mV member but in function uses APP.getApp().mV

    - error is in FuncX calling from onExitSleep in line mD.mX = 0

    where should I use weak? and why?

  • weak() is used for circular dependencies.  Sound like you have something else going on, so no need for weak.

  • I keep reading and re-reading that article.

    AFAIK, I understand it... but I still cannot work out how it applies here.

    The line where the error is thrown is a method call on self - and you cannot have a "weak()" defined class member.

    Inside the method itself (pasted above) there is nothing that I see that even _can_ be defined as "weak()".

    isAOD and requiresBurnInProtection are both boolean,

    displayGraph is a BufferedBitmap.

    All the other values are simple Number.

    Therefore, the only possibility I can see is the displayGraph / BufferedBitmap but I cannot see any way that a circular reference could be created with that as there is no reference to my class with the buffered bitmap that I use with the class. (And, furthermore, I _ABSOLUTELY_DO_NOT_ want to allow the buffered bitmap to be cleared away unless I clear it away or my app is destroyed.

    Maybe I'm being dense here, but I can't see how it applies in this situation.

  • (Not to mention that using .weak() with BufferedBitmap causes a crash in any case.)

  • Which device?  Recall that with a 4.x device, the graphics pool is involved.