Widget Second Screen

Former Member
Former Member
For my widget I am trying to develop a second screen.

I have added a new view using a listener on the enter event:

function onKey(evt) {
if (evt.getKey() == Ui.KEY_ENTER) {
Ui.pushView(new CView(), new CDelegate(), Ui.SLIDE_DOWN);
return true;
}

return false;
}


I then want to enable returning back to the main view:

class CDelegate extends Ui.BehaviorDelegate {
function onBack() {
switchBack();
System.println("BACK");
return true;
}

function onNextPage() {
System.println("NEXT PAGE");
switchBack();
return true;
}

function onPreviousPage() {
System.println("PREVIOUS PAGE");
switchBack();
return true;
}

function switchBack() {
Ui.popView(Ui.SWIPE_DOWN);
}}


This works fine on the simulator. However when testing on my watch when returning from the second view the watch displays the normal watch face for a few seconds and then goes back to the main page of my widget. However the functionality is strange. For example it doesn't really respond to more keys except after a long delay. It's as almost as if the event is being captured first by the watch and then by the widget and something goes wrong. A similar thing happens with up or down. It momentarily returns to the main page of the widget and then goes to the next real widget - again as if the watch has captured the event.

When I look at the CIQ_LOG.txt log I get the following message:

TVM ERROR:
Circular Dependency Error
Unfreed memory on exit


I know that something like this must be possible because the widgets such as the Weather or barometer widget use the "enter" key and return functionality.

What I am doing wrong?
  • Former Member
    Former Member over 10 years ago
    What about the circular dependency error and unfreed memory? I am not doing the switch back but using the esd key and get the messages in CIQ_LOG


    I checked that the fix worked with regards to being able to transition back to the original page and it does. I did not get a chance to check the unfreed memory issue. I will do that later. The question is whether it matters if this error still occurs. In other words - it could be another bug that a false error is thrown or that perhaps the error does not matter.

    Can Brian shed some light on this?
  • I checked that the fix worked with regards to being able to transition back to the original page and it does. I did not get a chance to check the unfreed memory issue. I will do that later. The question is whether it matters if this error still occurs. In other words - it could be another bug that a false error is thrown or that perhaps the error does not matter.

    Can Brian shed some light on this?


    Have you run the app in the simulator and viewed its memory (File > View Memory)? This will tell you what is causing the circular dependency.
  • Have you run the app in the simulator and viewed its memory (File > View Memory)? This will tell you what is causing the circular dependency.


    Sorry Kyle. Can u explain more. How does viewing that able to determine what is causing the circular dependency? And what about the unfreed memory?
  • Former Member
    Former Member over 10 years ago
    I think there is an issue with using the auto pop (ignoring the back key and allowing the system to pop your last page) behavior that may cause the Circular References error to appear when you don't actually have any. The issue I described previously triggered the behavior because it caused the auto pop to occur.

    If you don't see the warning in the simulator when you close the app, you probably don't have Circular References. We are going to investigate the false report further.
  • Sorry Kyle. Can u explain more. How does viewing that able to determine what is causing the circular dependency? And what about the unfreed memory?


    It shows all the objects your app has created. If there's a circular reference between any of them it'll mark them with "CIRCULAR REFERENCE" in the notes section. As Brian said though, if you run the app in your simulator and don't get a pop-up when you close the app, it is probably a false report on the hardware and is something we'll have to investigate.
  • It shows all the objects your app has created. If there's a circular reference between any of them it'll mark them with "CIRCULAR REFERENCE" in the notes section. As Brian said though, if you run the app in your simulator and don't get a pop-up when you close the app, it is probably a false report on the hardware and is something we'll have to investigate.


    ack on that. I don't recall seeing that. Although I still have the "unfree memory" thing

    Thanks.