question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rotate device: App reloads overview-page

See original GitHub issue

Actual behaviour

Example:

  • In local WiFi
  • Open openHAB Android App --> Connected locally
  • Opens openHAB 3 UI
  • Go to custom subpage (e.g. Graph page)
  • Rotate device (e.g. to have a better overview about the shown graphs)
  • App seems to completely reload openHAB 3 UI and jumps back to Overview page
  • I have to navigate the whole way to the custom page i want

Expected behaviour

  • Currently open page stays open and is shown in new screen orientation

Steps to reproduce

  1. Open custom page
  2. Rotate the device

Environment data

Client

  • Android version: 12 beta
  • Device model: Pixel 3a
  • App version : 2.17.3-beta

Logs

App log

Click to expand
-----------------------
Device information
Model: Pixel 3a
Manufacturer: Google
Brand: google
Device: sargo
Product: sargo
OS: 11
Display: 1080x2176, 2.3375 density
Data usage policy: DataUsagePolicy(canDoLargeTransfers=true, loadIconsWithState=true, autoPlayVideos=true, canDoRefreshes=true), data saver: 1, battery saver: false
-----------------------

--------- beginning of events
05-26 09:46:10.364 22698 22698 I wm_on_create_called: [117183046,org.openhab.habdroid.ui.MainActivity,performCreate]
05-26 09:46:10.383 22698 22698 I wm_on_start_called: [117183046,org.openhab.habdroid.ui.MainActivity,handleStartActivity]
05-26 09:46:10.402 22698 22698 I wm_on_resume_called: [117183046,org.openhab.habdroid.ui.MainActivity,RESUME_ACTIVITY]
05-26 09:46:10.427 22698 22698 I wm_on_top_resumed_gained_called: [117183046,org.openhab.habdroid.ui.MainActivity,topStateChangedWhenResumed]
05-26 09:46:26.187 22698 22698 I wm_on_top_resumed_lost_called: [117183046,org.openhab.habdroid.ui.MainActivity,pausing]
05-26 09:46:26.201 22698 22698 I wm_on_paused_called: [117183046,org.openhab.habdroid.ui.MainActivity,performPause]
05-26 09:46:26.206 22698 22698 I wm_on_stop_called: [117183046,org.openhab.habdroid.ui.MainActivity,handleRelaunchActivity]
05-26 09:46:26.325 22698 22698 I wm_on_destroy_called: [117183046,org.openhab.habdroid.ui.MainActivity,performDestroy]
05-26 09:46:26.432 22698 22698 I wm_on_create_called: [117183046,org.openhab.habdroid.ui.MainActivity,performCreate]
05-26 09:46:26.493 22698 22698 I wm_on_start_called: [117183046,org.openhab.habdroid.ui.MainActivity,handleStartActivity]
05-26 09:46:26.524 22698 22698 I wm_on_resume_called: [117183046,org.openhab.habdroid.ui.MainActivity,RESUME_ACTIVITY]
05-26 09:46:26.524 22698 22698 I wm_on_top_resumed_gained_called: [117183046,org.openhab.habdroid.ui.MainActivity,topWhenResuming]
05-26 09:46:30.048 22698 22698 I wm_on_top_resumed_lost_called: [117183046,org.openhab.habdroid.ui.MainActivity,topStateChangedWhenResumed]
05-26 09:46:30.055 22698 22698 I wm_on_paused_called: [117183046,org.openhab.habdroid.ui.MainActivity,performPause]
05-26 09:46:30.138 22698 22698 I wm_on_stop_called: [117183046,org.openhab.habdroid.ui.MainActivity,STOP_ACTIVITY_ITEM]
05-26 09:50:52.910 22698 22698 I wm_on_destroy_called: [117183046,org.openhab.habdroid.ui.MainActivity,performDestroy]
--------- beginning of main
05-26 09:50:53.276 22698 22698 D MainActivity: onCreate()
05-26 09:50:53.318 22698 22698 D ContentController: onRestoreInstanceState()
05-26 09:50:53.318 22698 22698 D PageConnectionHolderFragment: updateActiveConnections: URL list [], connection org.openhab.habdroid.core.connection.DefaultConnection@95ef6ca
05-26 09:50:53.332 22698 22698 D MainActivity: Got intent: Intent { act=org.openhab.habdroid.action.OH3_UI_SELECTED cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.openhab.habdroid.beta/org.openhab.habdroid.ui.MainActivity bnds=[859,1336][1028,1529] }
05-26 09:50:53.334 22698 22698 I wm_on_create_called: [117183046,org.openhab.habdroid.ui.MainActivity,performCreate]
05-26 09:50:53.335 22698 22698 D MainActivity: onStart()
05-26 09:50:53.578 22698 22698 D PageConnectionHolderFragment: onStart(), started false
05-26 09:50:53.589 22698 22698 D ServerConfiguration: load: ServerConfiguration(id=2, name=openhabian, localPath=ServerPath(url=http://<openhab-local-address-openhabian>:8080/, userName=<none>, password=<none>), remotePath=ServerPath(url=https://<openhab-remote-address-openhabian>/, userName=<redacted>, password=<redacted>), sslClientCert=null, defaultSitemap=DefaultSitemap(name=uicomponents_page_8ba312a15d, label=New Sitemap), wifiSsid=null)
05-26 09:50:53.591 22698 22698 D ServerConfiguration: load: ServerConfiguration(id=2, name=openhabian, localPath=ServerPath(url=http://<openhab-local-address-openhabian>:8080/, userName=<none>, password=<none>), remotePath=ServerPath(url=https://<openhab-remote-address-openhabian>/, userName=<redacted>, password=<redacted>), sslClientCert=null, defaultSitemap=DefaultSitemap(name=uicomponents_page_8ba312a15d, label=New Sitemap), wifiSsid=null)
05-26 09:50:53.594 22698 22698 D MainActivity: onActiveConnectionChanged()
05-26 09:50:53.629 22698 22698 D ServerConfiguration: load: ServerConfiguration(id=2, name=openhabian, localPath=ServerPath(url=http://<openhab-local-address-openhabian>:8080/, userName=<none>, password=<none>), remotePath=ServerPath(url=https://<openhab-remote-address-openhabian>/, userName=<redacted>, password=<redacted>), sslClientCert=null, defaultSitemap=DefaultSitemap(name=uicomponents_page_8ba312a15d, label=New Sitemap), wifiSsid=null)
05-26 09:50:53.630 22698 22698 D MainActivity: Cannot auto select server: No server with configured wifi
05-26 09:50:53.630 22698 22698 D PageConnectionHolderFragment: updateActiveConnections: URL list [], connection org.openhab.habdroid.core.connection.DefaultConnection@95ef6ca
05-26 09:50:53.631 22698 22698 I wm_on_start_called: [117183046,org.openhab.habdroid.ui.MainActivity,handleStartActivity]
05-26 09:50:53.631 22698 22698 D MainActivity: onPostCreate()
05-26 09:50:53.632 22698 22698 D MainActivity: onResume()
05-26 09:50:53.658 22698 22698 I wm_on_resume_called: [117183046,org.openhab.habdroid.ui.MainActivity,RESUME_ACTIVITY]
05-26 09:50:53.659 22698 22698 I wm_on_top_resumed_gained_called: [117183046,org.openhab.habdroid.ui.MainActivity,topWhenResuming]
05-26 09:50:53.732 22698 22698 I Choreographer: Skipped 65 frames!  The application may be doing too much work on its main thread.
05-26 09:50:53.802 22698 22698 D AbstractWebViewFragment: progressCallback: progress = 10
05-26 09:50:53.803 22698 22698 D AbstractWebViewFragment: progressCallback: progress = 10
05-26 09:50:53.807 22698 22851 D ConnectionFactory: checkAvailableConnection: found types [ConnectionType(type = Wifi, network=111)]
05-26 09:50:53.807 22698 22851 D AbstractConnection: Checking reachability of http://<openhab-local-address-openhabian>:8080/ (via 111)
05-26 09:50:53.811 22698 22698 D AbstractWebViewFragment: progressCallback: progress = 10
05-26 09:50:53.811 22698 22713 I OpenGLRenderer: Davey! duration=1160ms; Flags=1, FrameTimelineVsyncId=1194760, IntendedVsync=58142117760604, Vsync=58143201093894, InputEventId=0, HandleInputStart=58143209781623, AnimationStart=58143209783706, PerformTraversalsStart=58143212094123, DrawStart=58143267114545, FrameDeadline=58142134427270, SyncQueued=58143271186993, SyncStart=58143271583348, IssueDrawCommandsStart=58143271738296, SwapBuffers=58143277080952, FrameCompleted=58143280297359, DequeueBufferDuration=24063, QueueBufferDuration=565313, GpuCompleted=58143280297359, SwapBuffersCompleted=58143278368557, DisplayPresentTime=0,
05-26 09:50:53.811 22698 23430 I okhttp.OkHttpClient: --> GET https://<openhab-remote-address-openhabian>/api/v1/settings/notifications
05-26 09:50:53.811 22698 23430 I okhttp.OkHttpClient: User-Agent: Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19
05-26 09:50:53.811 22698 23430 I okhttp.OkHttpClient: Cache-Control: no-cache
05-26 09:50:53.811 22698 23430 I okhttp.OkHttpClient: --> END GET
05-26 09:50:53.812 22698 22698 D MainActivity: onCreateOptionsMenu()
05-26 09:50:53.814 22698 22698 D MainActivity: onPrepareOptionsMenu()
05-26 09:50:53.816 22698 22851 D AbstractConnection: Socket connected (attempt  0)
05-26 09:50:53.817 22698 22851 D ConnectionFactory: Connecting to local URL via ConnectionType(type = Wifi, network=111)
05-26 09:50:53.960 22698 22698 D AbstractWebViewFragment: progressCallback: progress = 70
05-26 09:50:53.960 22698 22698 D AbstractWebViewFragment: progressCallback: progress = 70
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: <-- 200 OK https://<openhab-remote-address-openhabian>/api/v1/settings/notifications (427ms)
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: Server: nginx/1.18.0 (Ubuntu)
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: Date: Wed, 26 May 2021 07:50:54 GMT
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: Content-Type: application/json; charset=utf-8
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: Content-Length: 35
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: Connection: keep-alive
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: X-Powered-By: Express
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: ETag: W/"23-/xrOAw4kk/UMX+JDa+0r4GFH8rY"
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: Set-Cookie: ██
05-26 09:50:54.239 22698 23430 I okhttp.OkHttpClient: <-- END HTTP
05-26 09:50:54.241 22698 22698 D MainActivity: onActiveCloudConnectionChanged()
05-26 09:50:54.250 22698 22698 D MainActivity: onPrimaryCloudConnectionChanged()
05-26 09:50:54.344 22698 23013 D FcmRegistrationService: Register device at openHAB-cloud with URL: addAndroidRegistration<redacted> 

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:39 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
s-pwcommented, May 28, 2022

‘This’ being what exactly?

Removing this line (or rather: avoiding the loadUrl call in that case) probably has the same effect, doesn’t it?

The fragment being recreated on activity recreation is expected behavior. Or what exactly does ‘every time’ mean? The stack trace makes it look like the app was opened by a shortcut to OH3 UI?

Example Steps:

  1. Open OH app navigate to Location->Garage->Properties->Garage Opener to open the door
  2. Go to the Android home screen or switch to other app to do other stuff
  3. Open OH app again from the homescreen or use app switcher

Expected:

  • The app is brought up from the background as is (with the state that was left so I can quickly close the garage door).

Actual:

  • The entire app reloads not only losing any progress but also taking a long time to load outside a home on a weak WiFi connection. I can’t think why that would be expected behavior as now I need to wait 3-5 seconds for the app to load and navigate again Location->Garage->Properties->Garage Opener to close the door that was just opened using this app.

I’m not arguing that from a code perspective this is what we should do on activity recreation, my point is this is what is breaking usability, maybe the proper fix should be to figure out why we do activity recreation when you switch to already running app in the background.

Which unfortunately is a combination of two ugly hacks.

I agree these are ugly hacks, this is why we need someone familiar with the project to come up with the correct solution. I would look into why we create a new instance of fragment when you switch into app from background.

1reaction
mueller-macommented, Aug 1, 2021

This patch avoids the reload of the WebView:

diff --git a/mobile/src/main/AndroidManifest.xml b/mobile/src/main/AndroidManifest.xml
index f2a01884..0b327bb5 100644
--- a/mobile/src/main/AndroidManifest.xml
+++ b/mobile/src/main/AndroidManifest.xml
@@ -81,6 +81,7 @@
             android:label="@string/widget_type_image" />
         <activity
             android:name=".ui.MainActivity"
+            android:configChanges="orientation|screenSize"
             android:label="@string/app_name"
             android:launchMode="singleTop">

However this breaks the change from one pane to two panes in the sitemaps. Maybe change AbstractWebViewFragment to an activity?

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Don't reload application when orientation changes
My app displays a random image when it first loads and rotating the device should not select another random image. How can I...
Read more >
Android screen rotation causes app to reload
If you rorate the screen, the Connect app reloads instead of displaying the page you were on in either landscape or portrait, thus...
Read more >
Domain Reloading - Unity - Manual
Domain Reloading resets your scripting state, and is enabled by default. It provides you with a completely fresh scripting state, and resets all...
Read more >
Android Studio - Stop Reload on Screen Rotation - YouTube
... Android app development. That is when you will rotate your mobile phone like the portrait to landscape mode, your website will reload....
Read more >
Amazon S3 - Cloud Object Storage - AWS
... mobile applications, backup and restore, archival, IoT devices, ML, AI, ... to reduce costs without upfront investment or hardware refresh cycles.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found