Android App loading slow

I have noticed that the Android App loads slow in Android whereas in Windows it is quite fast.
I have Philips Hue lights, 5 IP cameras, a Sony plugin, 3 Google Cast devices and HTTP calls to several Shellys and Cloud access for two Floods.
Are there any considerations to take into account to increase performance in Android? Thank you very much.

Generally speaking, your Windows PC is going to be a faster because it’s built with better hardware. Compare the CPU & memory of your PC to your Android device. The PC specs will probably look a little better. I myself have a high-end Samsung Galaxy S9 phone & the app loads pretty quick on it. On cheaper Android devices, your experiences may not be as good. If you are looking for ways to improve performance, take a look at your image directory. Consider optimizing them to shrink their size. Or better yet, check out the Home Remote’s built-in icons. These things might help but I can’t say for certain. It may have nothing to do with the images you are using.

From my experience I have not seen images hurt performance… at least I haven’t noticed it. My project is over 13MB.

Here’s where I see a different behavior in performance. Two examples with custom pages.

Ex1. Using many PageBrowsers on your home page and writing the IsVisible property to switch which ones are shown. When HR is starting up, all the PageBrowsers are processed at that time making it take longer for the page to load.
Ex2. Using one PageBrowser on your home page and writing the Page property. At startup only the one PageBrowser is processed making the page load faster. The trade-off is when the Page property changes, it has to process the new page, so it takes a moment longer at that time.

I have dedicated tablets so I would prefer EX1 with a longer load time but lightning fast changes once loaded. My point here is; the structure of your layout may change the performance.

Also, did you setup your project to update from an FTP server? This makes HR look for an updated project on the FTP server at startup and gives you a spinning-circle before it says “loading”. I believe I’ve read this times out after 5 seconds? This is actually a great feature but, I have been on the fence if I like how it does this at startup (perhaps it should just ask when I hit the restore button).

Thanks for your replies!
I have 5 content pages
Page 1 with 3 control selectors

  • 3 device browsers for lights (6 Hue lights + 4 Hue lightstrips + 1 Hue plug + 10 Shellys HTTP)
  • 3 device browsers for 1 shelly flood (Cloud) + 2 shelly shutters (HTTP) + 2 shelly shutters (HTTP)
  • 2 device browsers for 1 Sony TV plugin + 3 Google Cast (Sony TV + 2 Google Home mini) + a grid for 5 WoL PCs

Page 2 with 3 device browsers for 5 IP Cameras that load their live stream as miniature and a button to open a Windows Remote Desktop PC

Page 3 with 3 device browsers for lights (7 Hue lights + 1 Shelly HTTP)

Page 4 with 1 device browser for 1 shelly flood (Cloud)

Page 5 with 2 device browsers for lights (2 Shellys HTTP + 1 Hue plug) + 1 WoL PC

The video streams seem to load only when the page is called which is good. I am not sure about the rest which seem to be called on load because the access is fast after loading HR?

I have another concern. When defining a Device Browser, besides the Group, what do you have to put in the DeviceGroup? For Hue lights I put the Hue group of lights in “Value”, but for other devices what needs to be used? I usually use the Capabilities Device Binding of one of the devices. Is this correct?

What happens if in one group you have a mix of Hue lights with other devices like the Shellys? Right now I use the Hue group of lights, but I am not sure whether this is correct and whether this might make HR slower?

Thank you very much for your help and advice!

How would you recommend to organize the device browsers to avoid loading all of them at startup, to speed up the loading process? I have different buildings (a group per building) and I group the devices by floors (a group per floor inside each building group). Is it possible to avoid loading all content pages at startup? Right now I have each building as a content page and each floor or special devices group is organized as a GridView ControlSelctor inside the content page. Many thanks!

There isn’t going to be a 1 size fits all solution. These are your Android devices & your projects. Maybe there’s 1 thing in your project that’s causing this, I don’t know. The best thing you can do is test. Try different things. Use the process of elimination to find out what’s slowing everything down. Create a new empty project & see how that performs. Compare the load times of the empty project to your project. I don’t think you are going to find any more advice from us on this subject. It’s ultimately going to be you that finds the solution.

At some point you also got to ask, might it be worth investing in a nicer tablet?

Bill, thanks for your recommendation. I startd a new project as suggested and I found out that the Shelly calls delay just a little bit the HR loading, but what really delays the loading is the Sony plugin (cast devices do not slow down too much)…
Can you recommend me what to look for inside the plugin? Is there a way to avoid loading it when starting HR?
I do not use dedicated devices, at least for now…
The project is 718KB with no images (just a light background) and my devices are not very old, i.e. a Samsung S9.

You can use the new HasSubscribers function.

It’s most likely not the plugin “loading” that is slowing it down. It’s what the code in the plugin is doing. That’s where HasSubcribers can help. You can add logic so that the main parts of your code only run when your views are loaded & active.

Look at your PollingInterval too. Make sure you aren’t polling crazy fast or anything. I generally do not do anything smaller than 1000ms.

Nice, I will try that ! I guess I should put it in the onPoll() as in your example… What about the onConnect() fucntion?
I am using a PollingInterval of 1000 because if I use 5000 the Sony TV responds too slowly.
I think the HasSubcribers might be the solution… Let me try it.
Thank you very much Bill !

I just tried it and what slows the loading is the onConnect(), of course. So, by putting the code in the loading of the Sony TV plugin the process is much faster, although when you go to the content page it takes a moment to load the TV. I think it is the trade off, but with no dedicated devices, as Jdamore was suggesting, that is a good solution.

My question is, do you think I should leave the HasSubcribers in the onPoll() as well? What will happen if I take it out, especially when the onPoll() is called and the onConnect() has not been loaded yet? Will the onConnect() be called? That might be a good solution to somehow “delay” the loading of the Sony TV, after all the other plugins are loaded by the first onPoll(), right? Am I too wrong?
If I do that, take out the HasSubcribers from the onPoll() but leave it in the onConnect(), then the loading of the plugin, when you go to its content page, takes forever? I do not know why?
Thank you very much Bill !!

What I recommend doing is moving your connection code into onPoll. Add a global boolean variable to your plugin that tracks whether or not your connection code has ran. Clear the boolean in onConnect, then in onConnect check if that is set or not. If it is clear & you have subscribers, run your connection code & set the boolean variable. That way this connect code isn’t executed on subsequent onPoll calls.

I see… What you mean is “Clear the boolean in onConnect, then in onPoll check if that is set or not …”, right? So onConnect will only have the variable code right? This way, all the plugins that would be candidates to use HasSubscribers will have their own variable.
I am sorry but I am not an expert really, would it be abusing too much of your time and patience to ask you to implement it in the “HasSubscribers.hrp” example you sent me? That will be extremely helpful :wink:
Many thanks Bill !

Bill, I gave it a try. Are the changes in the SonyTV.plugin I made correct ?
isLoadedSonyTV is a VirtualDeviceVariable and DefaultValue = false.
Could you please verify them whenever you have some time?
Many thanks!
SonyTV.plugin (12.9 KB)

Yes. Your isLoadedSonyTV variable is doing exactly what I described. That should help improve your load times.

Great! It does!

  1. Can I still put the plugin.Settings in the onLoad() ? Will this imply a delay? For some devices like the Shelly Cloud this is the only difference with the onPoll() which means that I will not even need a variable if I leave them alone in the onLoad() !! Alternatively I can load the plugin.Settings every time the onPoll() is loaded…, but it is ugly, and leave the onLoad() empty.

  2. What about a plugin that has several group of devices in different pages? How will the variable handle the devices’ groups? Do I need a variable for each group?

  3. Finally, if I have a plugin variable set at the top level, i.e. mode = getSettings.data.mode; or name = getSettings.data.relays[channel].name;, that will never change for that device, do I need to reset it at the onChangeRequest ? or it remains with its value for each device instance?

Many thanks Bill ! And sorry for my lack of knowledge with these basic questions…

  1. Loading settings shouldn’t take any time to load. I wouldn’t make any changes for that.
  2. Each device has it’s own HasSubscribers function. You can write your own that checks them all. Here’s a code snippet below that you can copy into your project.
  3. I don’t know. You’ll have to test to find out. It’s up to you how you want to handle that.
function shouldPoll() {
    if (plugin.Devices) {
        for (var d in plugin.Devices) {
            var device = plugin.Devices[d];
            if (device.HasSubscribers()) {
                return true;
            }
        }
    }
    return false;
}

Bill, I have noticed that after loading a page, I mean running onConnect(), I always get HasSubscribers() = null even when there are subscribers. I have also noticed that after onConnect(), onPoll() is called, which is great, but HasSubscribers() is null !!, and it is placed inside onPoll(). It is only after the second onPoll() that HasSubscribers() returns true…? Am I correct? Am I missing something? This might be a reason why loading some devices takes so long, because the first time there are never subscribers and the speed will depend on the PollingInterval… In the case of the Nest thermostat the PollingInterval is quite high 30000 to avoid too many HTTP calls and it takes very long to load.
I apologize if I am totally wrong in my deductions, I am still learning and still too new on this… :wink:
Many thanks!

When the app 1st connects & when it runs your 1st onPoll, there probably aren’t any subscribers because the page is still loading. The speed at which the next time onPoll is called will depend on the PollingInterval you’ve defined.

If it were me, I’d have this plugin always refresh your thermostats on its 1st run, regardless of whether there are any subscribers. Then on the subsequent runs use your HasSubscribers.