thecowan / wallpanel-android

WallPanel is an Android application for Web Based Dashboards and Home Automation Platforms
https://wallpanel.app
Apache License 2.0
750 stars 103 forks source link

Wallpanel closes itself #24

Closed Marooned-MB closed 6 years ago

Marooned-MB commented 6 years ago

Hi I'm using old tablet with Android 4.2.2 and was successfully running WallPanel for a few days displaying my Node-RED dashboard. Today when I tried to run it again, it showed white blank page and then closed itself (returned to launcher) leaving permanent notification "WallPanel Running...". Clicking on that brings back white page and it returns to launcher again.

I've cleaned data for the app and it then runs normally with the welcome screen asking to configure everything. Once I set url for my Node-RED dashboard it goes back to blank screen and then to launcher.

Any clues? Any debug log to track the issue? I don't recall doing any major changes to my dashboard (or even any changes to be honest). It was working fine just a day earlier.

Well, I've just tried to leave default URL and click Dashboard button on the top right and it behaves exactly the same. Blank page and then quits, so it's not my dashboard fault. Running without access to the network (just for testing purpose) does the same. I've also tried to reinstall the app, didn't help.

BTW, it stores 13,2MB of data after initial run, what is that? Sounds crazy for a few settings.

thanksmister commented 6 years ago

I really don't know what's the issue. I have logs but they are private. Can you give me your OS and device so that can see if the logs show anything. Also what version of the application are you running and did you install it from Github or from Google Play. As far as storage, I have no idea how big it should be, its storing only the preferences but it could be additional google libs.

Marooned-MB commented 6 years ago

Sure, some details (rather not common device) Model: TB Touch Ignis 8 Android: 4.2.2 Installed from Google Play.

As mentioned, it was working flawlessly for a few days running Node-RED dashboard and utilizing MQTT. Tablet config hasn't changed

thanksmister commented 6 years ago

The application isn't going to suddenly break, its just running the same code. Sounds like a rendering issue with the browser webpage but I don't see any reports of crashes for version v0.8.4-beta.3 which is the latest release. Instead of the default URL try just "https://google.com" to see if that renders without crashing. Also be sure that its not an issue with the camera and leave the motion/face detection off as well as disable the camera. There is also a setting to render the webpage using the legacy browser, which it probably already is given how old your device is.

thanksmister commented 6 years ago

I do see some camera crashes for an older 4.0 OS device, but it's an Asus and its for v0.8.4-beta.2. It can happen that sometimes on older devices the camera gets locked if you use other applications that also use the camera. The only way to fix this is to restart the device and be sure only one application that accesses the camera is running.

Marooned-MB commented 6 years ago

It was working fine with the camera (both motion detection and face detection), so it's not that (anyway, by default it's disabled). The only thing that was not working was TTS, else was fine.

Anyway, I managed to display the dashboard after changing browser engine to Android WebView and almost all looks good except wave gauge. It was also looking fine just yesterday.

So.. looks like automatic selection of browser engine picking Crosswalk Project is failing? I don't know which engine was picked on the previous days but judging by the proper render of wave, it was not WebView? So, if we nailed down the problem to Crosswalk, can it be debugged somehow? I have root, I could also install ADB to read Logcat if that could help.

thanksmister commented 6 years ago

Based on your OS, the automatic browser would default to Crossealk. That’s the logic in the application, it checks for anything below Android 5.0.

thanksmister commented 6 years ago

The logic part of the application which determines the browser value is as follows:

 private fun startBrowserActivity() {
        Timber.i("startBrowserActivity Called")
        val browserType = configuration.androidBrowserType
        val targetClass: Class<*>
        when (browserType) {
            "Native" -> {
                Timber.i( "Explicitly using native browser")
                targetClass = BrowserActivityNative::class.java
            }
            "Legacy" -> {
                Timber.i("Explicitly using legacy browser")
                targetClass = BrowserActivityLegacy::class.java
            }
            "Auto" -> {
                Timber.i("Auto-selecting dashboard browser")
                targetClass = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    BrowserActivityNative::class.java
                else
                    BrowserActivityLegacy::class.java
            }
            else -> {
                Timber.i("Auto-selecting dashboard browser")
                targetClass = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    BrowserActivityNative::class.java
                else
                    BrowserActivityLegacy::class.java
            }
        }
        val intent = Intent(this@WelcomeActivity, targetClass)
        intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
        startActivity(intent)
        finish()
    }

Browser type is from the settings and if its auto, it will check for anything equal to or below Lollipop, which is Android 5.0. If its below that, it will try to run Crosswalk unless manually overridden in the settings. It could be that initially, the browser setting isn't set to anything, which would still default to Crosswalk for any OS below Android 5.0.

Marooned-MB commented 6 years ago

I can see that the app has been updated 3 days ago, maybe Crosswalk was updated with it? I could install previous version (if it's available somewhere?) to run tests if it'll work? That could give some hints where's the root of the issue?

thanksmister commented 6 years ago

Does your version of Android support TTS? I have to check but there is also a minimum value for running TTS governed by Google services.

thanksmister commented 6 years ago

Crosswalk is a dead project, there are no more updates for Crosswalk. You can find all previo versions of the aplicación here in Github under the release section.

Marooned-MB commented 6 years ago

Yes, it has TTS (Pico TTS). I've followed https://github.com/mdn/web-speech-api/ -> https://mdn.github.io/web-speech-api/speak-easy-synthesis/ and it properly shows all my installed languages and properly read provided text. Looks like I could just use this code to add simple mqtt->ui_template with such JS - will check that later.

Anyway, I've uninstalled latest version from Google Play and installed v0.8.4-beta.1 from github and.. all is working fine with automatic/crosswalk, wave gauge renders properly, so some breaking change has been introduced in the latest version.

thanksmister commented 6 years ago

Ok, I’ll have to see what was changed. So if you send a TTS command to the WalPanel application it doesn’t speak?

Marooned-MB commented 6 years ago

As for the TTS (should be moved to a different issue probably): if I use "audio out" node (from standard library), then I can see small popup in the top right corner saying: Computer says... <my message>. However, if I use MQTT to publish {"speak": "Hello!"}, nothing happens. And my MQTT is correct as {"wake": true} correctly wakes up the tablet.

thanksmister commented 6 years ago

I have tested TTS from Home Assistant, it appears to be working as expected. Could it be that you have incorrectly setup your MQTT? I have tested it on a pretty old device as well, a Nexus 5 with Android 6.0.1. I sent the following MQTT message after setting up MQTT in the settings:

{"topic":"wallpanel/mywallpanel/command", "payload":"{'speak':'Hello!'}"}

thanksmister commented 6 years ago

BTW, it stores 13,2MB of data after initial run, what is that? Sounds crazy for a few settings.

I am seeing 7.5 MB of cached storage. It uses 108 MB total for the application, 100 MB for the app itself, plus the 7.5 MB of data. It doesn't have a database, just using shared preferences for storage.

thanksmister commented 6 years ago

I tested TTS on an old Nexus 7 running Android 5.1.1. I have not older devices to test Android 4. TTS worked as expected. I have not encountered an issues with WallPanel closing on the latest version, but still testing to see if its MQTT related or some dialog causing a crash.

Marooned-MB commented 6 years ago

heh, forgot to disable automatic updates in Google Play, Panel updated itself and didn't start, I had to remove it and manually install again from apk (any progress on that one? I can run some debug version if you have one)

As for the two additional subjects that are generally outside of the scope of this report. 1) I've tested panel also on Samsung S5 - TTS works here (so config is correct), so it's not working only on the tablet 2) let's leave the storage subject - I was just surprised that after initial run it creates few MB of different files, never mind, that's not important, it's not 600MB like Facebook or Messenger ;)

thanksmister commented 6 years ago

I don't see any errors that stick out with the latest version on my older tablet. I do see a lot of disconnects/reconnects with the MQTT service. My theory is there is some dialog issue on the device that probably causes a crash. I may disable any alerts that show an MQTT service error or provide an option to disable them since they happen frequently on older devices but the MQTT client reconnects or tries to reconnect automatically. It's hard to be sure though, since your device is running an OS that I don't have to test. I will post something maybe tomorrow or the next day for you to test before I push it up to Google Play.

Marooned-MB commented 6 years ago

Feel free to ping me if you want my QA on this tablet (my plan is to hang it on the wall permanently so would be nice to be able to update to the newest versions). Happy to help and thanks for the great work so far.

thanksmister commented 6 years ago

Awesome, thanks man. I will release the APK here on Github first, so you can test it out.

thanksmister commented 6 years ago

Let's try https://github.com/thanksmister/wallpanel-android/releases/tag/v0.8.4.4 and see if this resolves the issue or points to the problem with the dialogs.

Marooned-MB commented 6 years ago

Unfortunately, the same issue. White page then back to launcher (or previous running app) leaving "WallPanel is running" permanent notification (shown after ~1s or so). But do I see correctly that this version changed only 2 readme files? Or does github shows this so strangely?

thanksmister commented 6 years ago

I haven't checked in changes yet as I am still testing. I have to duplicate the issue on a 4.0 device, there is no way around. You have specific issue that I am just guessing how to fix. I will let you know when I have a fix.

thanksmister commented 6 years ago

I resurrected an old Android 4.3 device and was able to duplicate the issue. I rolled the code back to the previous working version and gradually adding changes to find the breaking change. There was no crash reported, so this might be related to Android build versions.

thanksmister commented 6 years ago

OK, so I think I have some bad news and good news. It appears that when I updated to the latest Android Studio build tools and gradle, Crosswalk is no longer supported. Now that means going forward, I may have to remove Crosswalk all together. It's a dead project and it looks like it is no longer compatible with updated Android tools. I don't use Crosswalk in my other applications since this was legacy code when I took over the project.

thanksmister commented 6 years ago

I am closing this issue as the fix is to not use Crosswalk or give an option to use crosswalk. There is still a possibility to change the User Agent of WebView to see if you have better rendering results. Or you must stay on an older version of the application.

Marooned-MB commented 6 years ago

Whoaa, not the solution I was expecting... can this project be built with older Android studio to keep recent changes and Crosswalk?

thanksmister commented 6 years ago

Yeah, you can do that but you would freeze yourself to that version of gradle and build tools. It's because Crosswalk has long been a dead project and nobody is supporting that project. You still have the older APK versions that will continue to work, you just can't update to the latest version. The last build tool version compatible with Crosswalk is 27.0.2.

Marooned-MB commented 6 years ago

Well then, too bad. Anyway, thanks for the great effort to track that down. Cheers man!

thanksmister commented 6 years ago

Best of luck, you may want to take a look at Fully Kiosk Browser to see how their rendering does.

Marooned-MB commented 6 years ago

I like your MQTT features. No worries, I'll stick to that last working version for now.

thanksmister commented 6 years ago

Yeah, with just WebView, I can no longer render my HASS page, going to try the user agent.

thanksmister commented 6 years ago

I could fork the project and only support the legacy browser on that fork. It will probably not be updated often but at least it can support older devices.

thanksmister commented 6 years ago

I have created a fork of this project to support Crosswalk: https://github.com/thanksmister/wallpanel-android-legacy

Marooned-MB commented 6 years ago

Thanks for the update. So will you be porting changes from this repo to legacy one and compile that one with older tools? You probably have access to Google stats to see how many users uses that old Android for this app. Do you plan to push legacy app to Google Play so we can have automatic updates?

Thanks again for your effort to support old devices (that IMHO are perfect to this purpose) :)

thanksmister commented 6 years ago

Unfortunately because building this project requires an older set of build toools, it is unlikely that it will be maintained.

Not all older devices have issues with WebView and require Crosswalk, so this fork is just for the few that require Crosswalk.

I will not be putting this into Google Play because it will most likely not be updated.