Context menu bug: location.reload() causes extreme lag #747

mikefromcanada opened this Issue Mar 10, 2013 · 8 comments

3 participants


Taking a look at the same code that I uploaded for another context menu bug.

The function: location.reload() seems to break the context menus.

In my example, I have a context menu that pushes a new bb screen.
On that screen I have a button that simply calls location.reload()
This refreshes the application and brings the user back to the main screen.

When attempting to use the context menus again, there is a delay of about 17-20 seconds (in simulator) from clicking on the context menu item until the page loads.
There are also some graphical glitches with the selected item that is calling the context menu (highlight stays blue, but text changes from white to black).

The application also becomes laggy and unstable at this point.

Open Source Projects member

Not sure if this is a webworks thing or not.. I would have to look into it more. I would HIGHLY suggest not doing a location.reload(). It is EXTREMELY expensive in your application. Out of curiosity, why do you need to do a location.reload()?


I'm using it to get back to my main screen and re-init my DB when I'm several screens deep. Is there a more efficient way to pop a pile of screens off the stack?

Open Source Projects member

We cover this use case in issue #616 but there isn't a convenient way of doing it right now. What I'm worried about is that bb.init() will be called multiple times and in that int() call it also initializes the WebWorks context menu through the bbui webworks extension.

Also, the WebWorks context menu can only be cleared by removing an item based on its id.. I'm not sure what would happen with the context menu when the page is reloaded.. it may clear the context menu or it may not. I've never tried it.

There is also the open pull request #668 that allows popping to a screen. But it has not been reviewed or merged.


Here's something else to add a bit more to the puzzle...the location.reload() only causes a problem with the context menu when it's called from a screen above the menu on the stack. If the page containing the context menu isn't on the stack, it doesn't cause any problems.

Open Source Projects member

Sounds like there could be some kind of issue with the linking of the context menu in WebWorks and the page reload. I'll ask the WebWorks team to take a look.

Open Source Projects member

I've just checked in a context menu update, can you see if that makes any difference with this issue?


Just tested with the newest version, but the issue is still there.
Context menu duplicates are fixed though :)
I've pulled the code out of my app for now anyway as per your suggestion. App is already pretty CPU heavy at times.


I found that the more you have on the screen stack, the longer it is for the context menu to come up. I'm not sure what exactly is the issue underneath. My app used to do a lot of pushscreens and performance wasn't a problem. I suppose the new context menu made it a lot more obvious and now I make sure I pop every screen that gets pushed and the lag is gone or at least isn't apparent.

Doing location.reload() probably adds to that issue, it'd probably be beneficial if we can pop more than one screen off the stack at a time, or all screens on the stack except the first one.

@tneil tneil closed this Jul 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment