pebble / pebblejs

Program the Pebble with simply JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Large Menus Prone to Crash (Aplite)

gitgud-software opened this issue · comments

I've been encountering reliability issues with the way menus function recently, at least on the Aplite platform. Something is causing issues with menus in my Trefoil app, which generates long lists of threads and upon selecting a thread, the posts inside them from AJAX calls:

https://github.com/gitgud-software/trefoil

Aplite builds of Trefoil have a tendency to crash reproducibly when attempting to browse any thread list from any board past Page 4, and with there being 15 threads per page, this means the crash occurs anywhere past 60 entries. If it's an issue of memory, this may be on top of the Board List Menu that the user is prompted with when opening the application. An example JSON call that generates the menus in question can be found here:

https://a.4cdn.org/g/catalog.json

Similar crashes occur when opening threads with several replies, though I haven't been able to get a fixed number at which the menu fails.

The emulator on CloudPebble, rather than crash hard when these problems occur, simply stops displaying menu text entirely, but allows for the menu to be scrolled. No error message is produced upon encountering this failure.

No problems have been encountered on Basalt though. This also didn't used to occur with previous Aplite builds, and with recent changes only having been made to support color for Basalt, the likely culprit is either in pebble.js's or the 3.0 SDK's handling of Aplite.

I'm still encountering this problem as of SDK 3.7 and the latest commits to pebble.js with Aplite, both Basalt and Chalk builds have been running without encountering any problems.

Ah, thanks for reminding me. I was meaning to take a look. I believe your assessment of it being a memory issue is very likely since menu items aren't automatically truncated which might be able to mitigate this issue. Regardless, I should still make sure that the JavaScript can't cause the C side to run out of memory for this particular case.

As a work around, you could try truncating the text that goes into menu items, and leaving the cards to have the full text.

Even displaying each thread title/content as a substring of no more than 5 characters, I find that at the most I have been able to keep the crash from happening until I hit Page 5 of any given board's catalog. I did see improvement, but it remains minimal.

Ah, thanks for testing quickly! I think what I may do is revert the cache amount for aplite to the original working amount, and bump it up when I've improved the memory handling to dynamically deallocate likely unnecessary items when low on memory. This quick revert will be for aplite only since it seems fine on other platforms.

Thanks, in observation the menu where the problems start (the catalog) is the only one that utilizes sections at all. Perhaps it's the way that sections are represented in memory that's eating up space?

Hmm, yes, sections are a little tricky to handle since they complicate the tricks one can use to implement infinite scrolling with finite visible items, particularly in that they do not have the same height as a menu item. Thanks, I'll keep that in mind when I look into this. Evidently, there is another open issue related to sections wherein the selection is not regained on return since sections > 0 are not preloaded on creation.

I just uploaded a branch bugfix-aplite-menu-cache-size, if you are able to test that, I may be able to add that in the cloudpebble PR I created recently as well. Otherwise I can schedule another update in a week or two.

Yeah, I can confirm that Trefoil is now building and running without error on Aplite. Thanks for the fix.