pebble / pebblejs

Program the Pebble with simply JavaScript
MIT License
455 stars 229 forks source link

App crashed when move from a Window to Menu #161

Open johnlamhc opened 8 years ago

johnlamhc commented 8 years ago

The app will be crashed while going from a Window to a Menu or return (click the back button) from a Window to a Menu.

johnlamhc commented 8 years ago

Example

Code:

//about window
function aboutWindow() {
  var aboutWindow = new UI.Window({ status: true });

  var bgRect = new UI.Rect({
    position: new Vector2(0, 0),
    size: new Vector2(144, 168),
    backgroundColor: 'white'
  });

  aboutWindow.add(bgRect);

  var logo = new UI.Image({
    position: new Vector2(32, 10),
    size: new Vector2(80, 80),
    image: 'images/Pebble-logo Large.png'
  });

  aboutWindow.add(logo);

  var titleText = new UI.Text({
    position: new Vector2(0, 90),
    size: new Vector2(144, 48),
    text: 'by johnlamhc',
    font: 'gothic-24',
    color: 'black',
    textAlign: 'center'
  });

  aboutWindow.add(titleText);

  aboutWindow.on('click', 'select', function(e) {
    aboutMenu();
  });

  aboutWindow.show();
}
//end of about window

//about menu
function aboutMenu() {
  var aboutMenu = new UI.Menu({
    sections: [{
      title: 'App Info',
      items: [{
        title: 'App Name',
        subtitle: 'Pebble.js',
      }, {
        title: 'Version',
        subtitle: '1.9.9 (2016/05/13)',
      }, {
        title: 'Creator',
        subtitle: 'johnlamhc',
      }, {
        title: 'Copyright',
      }]
    }, {
      title: 'Requirements',
      items: [{
        title: 'JSON (Pebble)',
        subtitle: '1.0.8',
      }]
    }]
  });

  //onSelect
  aboutMenu.on('select', function(e) {
    console.log('About' + [e.itemIndex]);
    if ([e.itemIndex] == 3) {
      copyrightCard();
    }
  });

  aboutMenu.show();
}
//end of about menu

When I am at "aboutWindow" and make a click, where the correct response will be jump to "aboutMenu", but the app crashed and give me the following error message:

ault_handling.c:79: App fault! {084ad721-fd3a-4321-a331-5d576478b861} PC: 0x50169042 LR: 0x805b839

Meiguro commented 8 years ago

Thanks for posting a minimal example!

In your testing, does this issue occur on Aplite and Basalt? It's possible the image is on the larger side, but I will verify on my end.

johnlamhc commented 8 years ago

I have tried and this issue happens on both Aplite and Basalt.

matopeto commented 8 years ago

I have same issue.

Return from card to menu.

PHONE] pebble-app.js:?: (-) [card 4] : [menu 3] [ERROR] ault_handling.c:79: App fault! {4a688611-683f-40d0-87f7-e94e1a358e0d} PC: 0x20656474 LR: 0x805b839

All platforms (emulators and watches). Compiled in CloudPebble.

linuws commented 8 years ago

This is not an issue for me any more. After some updates to CloudPebble it just started to work again. I'm using a Pebble Time (compiling for basalt + chalk). I have no idea what fixed the issue tho' - but try to compile one more time and see if works for you as well :)

matopeto commented 8 years ago

Still issue for me. I will try add minimal example that do not work for me.

matopeto commented 8 years ago

This is example that don't work for me (return from card to menu crashes the app)

/**
 * Welcome to Pebble.js!
 *
 * This is where you write your app.
 */

var UI = require('ui');

var menu = new UI.Menu({
    sections: [
        {
            items: [
                {
                    title: "item1",
                }
            ]
        }
    ]
});

menu.on('select', function(e) {
    var card = new UI.Card(
        {"title":"Dopravní uzavírky a omezení",
         "body":"ulice Gustava Geipela, mezi křižovatkami ulic Okružní a Hlavní, Aš, okr. Cheb, uzavřeno, oprava povrchu vozovky, Od 02.05.2016 00:00 Do 30.10.2016 23:59, V rámci rekonstrukce bude zcela uzavřena komunikace v celkové délce cca 360 m, od křižovatky s ul. Okružní, po okružní křižovatku s ul. Hlavní. Průjezd IZS bude zajištěn., Objížďka - bez rozlišení, Jiráskova, Okružní, Hlavní: Objížďka je stanovena přes ul. Jiráskova k.ú. AŠ v délce cca 500m, dále přes ul. Okružní a Hlavní, obě k.ú. AŠ v celkové délce cca 2 km., Vydal: Městský úřad Aš",
         "scrollable":true,
         "style":"large",
         "status":false
        }
    );
    card.show();
});

menu.show();

Error from console:

[PHONE] pebble-app.js:?: (+) [menu 1] : [menu 1]
[PHONE] pebble-app.js:?: (+) [card 2] : [menu 1],[card 2]
[PHONE] pebble-app.js:?: (-) [card 2] : [menu 1]
[ERROR] ault_handling.c:93: App fault! {7c4989ee-03bb-4105-be60-67e877e5c0f5} PC: 0x20656474 LR: 0x805d7db
pieteroskam commented 8 years ago

I'm also encoutering this problem. matopeto, did you fix it?

matopeto commented 8 years ago

@pieteroskam no I dont fix it, only workaround that works for me was trimming text length on card to cca 100 characters. (I think only windows with more content cause this issue)

andrei-markeev commented 8 years ago

Same stuff happens for me at least on Aplite - but not always, seems to be related to size of the body text or maybe some non-standard symbols in it.

dnschneid commented 8 years ago

Yeah, for my app, it is dependent on the amount of text in the card. 436 characters result in a crash on returning to the menu, but 418 characters are OK. It's the same limit on all three platforms.

rutgerkra commented 8 years ago

Is there any fix for this issue yet? I use a menu window to start a game window and after some interaction within the second window it crashed when called hide() instead of returning to the initial menu window. I think it's a memory issue, since it only comes up when some threshold is crossed in the second window...

unk1nd commented 7 years ago

[PHONE] pebble-app.js:?: (-) [menu 2] : [card 3] [PHONE] pebble-app.js:?: (+) [menu 2] : [card 3],[menu 2] [PHONE] pebble-app.js:?: (-) [card 3] : [menu 2] [ERROR] ault_handling.c:97: App fault! {46e9f5fc-9a8a-4921-94c6-3612f2afdb0f} PC: 0x8091db2 LR: 0x80921f7

Removed everything from the card. Still problems. Found that if i removed the banner in the card it did not crash.

johnlamhc commented 7 years ago

@unk1nd Any code same for the "banner" you mentioned? Thanks.

unk1nd commented 7 years ago
resultsMenu.on('select', function(e) {
      // Get server info
      var serverinfo = data.servers[e.itemIndex];

      // Assemble body string
      // 
      var content = "\nLast Seen:\n"+ serverinfo.last_update + "\n" +"\nIP: "+ serverinfo.ip + "\nHostname: "+ serverinfo.hostname + "\nAdmin: "+ serverinfo.admin + "\nLoad: "+ serverinfo.load;
      console.log('Showing info about ' + serverinfo.box);

      var BoxName = serverinfo.box;

      var icon_status = data.servers[e.itemIndex].status;
      var banner = "";
      if(icon_status == "Up"){
          banner = server_icon_up; 
      }
      if(icon_status != "Up"){
          banner = server_icon_down;
      }
      // Create the Card for detailed view
      var detailCard = new UI.Card({
        status: false,
        title: ' ' + BoxName,
        titleColor: '#899986',
        icon: title_icon,
        banner: banner,
        style: 'mono',
        body: content,
        bodyColor: '#ffffff',
        backgroundColor: '#336699',
        scrollable: true,
        action: {
          up: 'images/action_icon_up.png',
          down: 'images/action_icon_down.png',
          backgroundColor: '#e5e845',
        }
      });
      detailCard.show();
  });

This is the card code i use in my pebble.js app. It parses 3 items in a JSON from my server. Only one of them fail if i use banner and banner = server_icon_up. The image is a 4kb png image and from what i can see in the debug logs it is not eating up memory.

Let me know if you need more info. Don't want to share all of the code.

matopeto commented 7 years ago

Upping this bug, still happends with new package system.

Simplest code is:

/**
 * Welcome to Pebble.js!
 *
 * This is where you write your app.
 */

require('pebblejs') ;
var UI = require('pebblejs/ui');

var menu = new UI.Menu({
    sections: [
        {
            items: [
                {
                    title: "item1",
                }
            ]
        }
    ]
});

menu.on('select', function(e) {
    var card = new UI.Card(
        {"title":"Dopravní uzavírky a omezení",
         "body":"ulice Gustava Geipela, mezi křižovatkami ulic Okružní a Hlavní, Aš, okr. Cheb, uzavřeno, oprava povrchu vozovky, Od 02.05.2016 00:00 Do 30.10.2016 23:59, V rámci rekonstrukce bude zcela uzavřena komunikace v celkové délce cca 360 m, od křižovatky s ul. Okružní, po okružní křižovatku s ul. Hlavní. Průjezd IZS bude zajištěn., Objížďka - bez rozlišení, Jiráskova, Okružní, Hlavní: Objížďka je stanovena přes ul. Jiráskova k.ú. AŠ v délce cca 500m, dále přes ul. Okružní a Hlavní, obě k.ú. AŠ v celkové délce cca 2 km., Vydal: Městský úřad Aš",
         "scrollable":true,
         "style":"large",
         "status":false
        }
    );
    card.show();
});

menu.show();

result:

matej@MATEJ-WORK-PC:~/muj-ucet$ DISPLAY=:0 pebble install --emulator basalt --lo
gs
Installing app...
App install succeeded.
[15:04:47] pkjs> (+) [menu 1] : [menu 1]
[15:04:50] pkjs> (+) [card 2] : [menu 1],[card 2]
[15:04:51] pkjs> (-) [card 2] : [menu 1]
[15:04:51] ault_handling.c:97> App fault! {b0368ade-c5ca-4bc5-8947-66a0da42904c} PC: 0x20656474 LR: 0x8091daf
Program Counter (PC)    : 0x20656474 ???
Link Register (LR)      : 0x8091daf  ???

All platforms, current SDK.

This is logs from gdb:

Try `pebble gdb --help` for a short cheat sheet.
(gdb) c
Continuing.

Breakpoint 1, 0x080773d6 in app_crashed ()
(gdb) bt
#0  0x080773d6 in app_crashed ()
#1  0x0801e73a in ?? ()
#2  0x0801e796 in ?? ()
#3  0x08091dae in layer_mark_dirty ()
#4  0x080921f6 in ?? ()
#5  0x08092206 in layer_set_frame ()
#6  0x2001c562 in prv_update_layer_placement (self=self@entry=0x2001d0c8,
    frame_out=frame_out@entry=0x0) at ../src/c/simply/simply_window.c:143
#7  0x2001c77e in simply_window_set_status_bar (self=self@entry=0x2001d0c8,
    use_status_bar=<optimized out>) at ../src/c/simply/simply_window.c:159
#8  0x2001c940 in simply_window_load (self=self@entry=0x2001d0c8)
    at ../src/c/simply/simply_window.c:323
#9  0x20019e56 in prv_menu_window_load (window=0x2001d108)
    at ../src/c/simply/simply_menu.c:483
#10 0x08081290 in ?? ()
#11 0x080330e8 in ?? ()
#12 0x08039876 in ?? ()
#13 0x080310ec in ?? ()
#14 0x080803dc in animation_schedule ()
#15 0x08081166 in ?? ()
#16 0x08032fae in ?? ()
#17 0x0803a00c in ?? ()
#18 0x080305b0 in window_stack_push ()
#19 0x2001cb2a in show_window_sdk_3 (self=<optimized out>, window=0x2001d0c8,
---Type <return> to continue, or q <return> to quit---c
    is_push=<optimized out>) at ../src/c/simply/simply_window_stack.c:106
#20 0x2001cc38 in simply_window_stack_show (is_push=<optimized out>,
    self=<optimized out>, window=<optimized out>)
    at ../src/c/simply/simply_window_stack.c:136
#21 handle_window_show_packet (data=0x20026b82, simply=0x2001cf5c)
    at ../src/c/simply/simply_window_stack.c:174
#22 simply_window_stack_handle_packet (simply=simply@entry=0x2001cf5c,
    packet=packet@entry=0x20026b82)
    at ../src/c/simply/simply_window_stack.c:191
#23 0x2001a84a in handle_packet (simply=0x2001cf5c, packet=0x20026b82)
    at ../src/c/simply/simply_msg.c:201
#24 0x2001a8c8 in received_callback (iter=<optimized out>, context=0x2001cf5c)
    at ../src/c/simply/simply_msg.c:226
#25 0x0802c014 in ?? ()
#26 0x08050824 in ?? ()
#27 0x0802c4d2 in ?? ()
#28 0x0807cfec in app_event_loop ()
#29 0x2001925c in main () at ../src/c/muj-ucet.c:6
#30 0x08016928 in ?? ()
#31 0x00000000 in ?? ()
(gdb) c
Continuing.

please @Meiguro look at it

Threnklyn commented 1 year ago

any news regarding this issue? workarounds or fixes?