Android acting really slowly (simulator and ios ok)

Sorry about the late response.

I dove into this yesterday and discovered that our widget library is attempting to require-in a Lua file that isn’t there every time you create a new widget.  This is the cause of the performance issue.  It’s actually a performance issue on all platforms because file I/O is relatively expensive, and typically more expensive on Android because it involves peeking into the APK file which is really a zip file.

This issue started happening when we open sourced our widget library, because we modified it to support overriding our default/core implementation by adding a widget Lua library to your Corona project directory… in case you wanted to fork your own version based on what we have on bitbucket.

We did remove what was causing the “plugins.dex” warning, but that only reduced the performance issue by a tiny bit.  The real performance issue is still there.

We’ll look into solving this as soon as we can.

Thank you for the update Joshua.

Joshua, very good to hear that you are working on this. Looking forward to download a fixed daily build.

Good news! … holding breath :slight_smile:

Hate to nag but any idea on ETA for this fix?  This one is keeping us from releasing.

We also can’t release w/o this fix

This continues to stop our app release … please resolve this issue.  Android deployment is dead in the water till this is fixed.  Going back is not an option due to the bug fixes for Widget 2.0 and rolling back prior to Widget 2.0 is really out.  

Perhaps we jumped into the water too early.  Could really use a fix for this issue!

Please!

Thanks

An ETA would be much appreciated.  Is it a few days, a few weeks, or months?  It would be nice to know if I should begin working on rolling my code back to use the last public release and undoing all the Widget 2.0 changes.

Thanks.

We’ll have this issue resolved by the end of this week.

If you can’t wait, then your options are:

  1. Revert back to the last release version, build #1076.

  2. Use the widget Lua files we have on BitBucket instead.

   https://bitbucket.org/coronalabs/framework-widget

The reason option #2 above works around this problem is because our current widget code is attempting to require() in widget Lua files.  By adding those Lua files to your project, the require() will always succeed and prevent the performance issue.  The reason it is slow now is because the require() fails to find these files and falls-back to our core implementation.  When we fix this issue, we’ll have to modify our widget library to support both ways for those who still want to fork their own version of widgets, but without the performance issue.

Thanks Joshua.  That’s exactly what I needed to know.

Thanks for update.

So i am running out of time on this issue and need to look at your suggested work-around

I it tried to go to the bitbucket reference you posted above and it says i do not have access to that repository.  

Can you answer two questions:

  1. What is the proper location of the widget files

  2. exactly how do i use them?  (put them in my root directory with the name “widget” and they will take precidence?)

Thanks a bunch

m

Oh I’m sorry.  I pointed you to the wrong online repository.  You can find our widget source code here…

   https://github.com/coronalabs/framework-widgets

All widget Lua files are expected to be in a subdirectory named “widgetLibrary”.  The above repository has a “widgetLibrary” folder containing all of the widget Lua scripts.  That subfolder is the only you thing you need to work-around this problem, because all of the other widget files are already embedded in every Corona built app.

That said, we plan to finish testing our newest widget changes today.  If all goes well, this fix will be made available in tomorrow’s daily build, if you’re willing to wait for it.

seems to work!  Thanks for getting this one sorted out.

Joshua, this is great news! There were numerous daily builds yesterday so I’m a little confused with whats where. Can you kindly respond to this thread and confirm which build # includes this fix when its out? Thank you so much!

Everyone,
 
This issue is fixed in daily build #1126, which was just made available today.
Also, it would be great if you can let us know if this build solves this issue for you.
 
 
One more thing.  We’ve made a breaking change with how you can override our widget library with your own implementation or with what is on GitHub.  Our widget library will no longer look for your Lua files under the “widgetLibrary” subdirectory by default.  This is because that file lookup for a file that is not there was responsible for this performance hit.  But that said, we’ve came up with an even better solution that allows you to put your widget Lua files anywhere that you want to override Corona’s core widget implementation.  You can do so in your “main.lua” as follows…
 

-- Override Corona's core widget libraries with the files contained in this project's subdirectory. -- Argument "name" will be set to the name of the library being loaded by the require() function. local function onRequireWidgetLibrary(name) return require("widgetLibrary." .. name) end package.preload.widget = onRequireWidgetLibrary package.preload.widget\_button = onRequireWidgetLibrary package.preload.widget\_momentumScrolling = onRequireWidgetLibrary package.preload.widget\_pickerWheel = onRequireWidgetLibrary package.preload.widget\_progressView = onRequireWidgetLibrary package.preload.widget\_scrollview = onRequireWidgetLibrary package.preload.widget\_searchField = onRequireWidgetLibrary package.preload.widget\_segmentedControl = onRequireWidgetLibrary package.preload.widget\_spinner = onRequireWidgetLibrary package.preload.widget\_stepper = onRequireWidgetLibrary package.preload.widget\_switch = onRequireWidgetLibrary package.preload.widget\_tabbar = onRequireWidgetLibrary package.preload.widget\_tableview = onRequireWidgetLibrary

 
 
The above code affectively overrides Lua’s require() function for the above Lua libraries and calls the onRequireWidgetLibrary() instead.  That’s your opportunity to load your own widget Lua file from any directory that you want.  So, when you do the following in Lua…
 
   local widget = require(“widget”)
 
The above code will override that require call and load the “widgetLibrary/widget.lua” file instead of Corona’s core implementation.  In any case, I hope this makes sense.

@Joshua thanks for update about Android issue fix.

I didn’t understood your post about “package.preload.widget = …”. I have two questions:

  1. Should we still write in the code  ‘local widget = require(“widget”)’ or it is performed automatically from Corona’s core?

  2. If I want to change the button widget implementation, what steps should I do? As I understand, I should:

  a) to take a widget_button.lua file from this link:  https://github.com/coronalabs/framework-widgets

  b  ) to change it 

  c) to save in my project folder somewhere (if it is, then where to save?)

  d) to write the follow code in my main.lua:

      local function onRequireWidgetLibrary(name)
              return require(“widgetLibrary.” … name)
      end

      package.preload.widget_button = onRequireWidgetLibrary

   I guess I didn’t understood correctly the steps. Could you please explain it in a more detail way? 

>> Should we still write in the code  ‘local widget = require(“widget”)’ or it is performed automatically from Corona’s core?

Yes, this is the correct way of requiring in the “widget” library.  That aspect hasn’t changed.  By default, this will require in Corona’s core implementation unless you have a “widget.lua” file in your project’s root directory.

>> If I want to change the button widget implementation, what steps should I do?

This is what you should do:

  1. Download our “widget_button.lua” file from our GitHub repository.

  2. Copy the “widget_button.lua” file to your project’s root directory.

  3. Modify that Lua file to whatever you want it to do.

That’s it.  When you call the widget.newButton(), Corona will check if you have a “widget_button.lua” file in your root directory first before using its core implementation.  You only need to use the “package.preload” method I posted up above if you want to place your “widget_button.lua” in a subdirectory… or load a Lua file with a different name.

@Joshua thank you, I understood completely.