split-it-easy-android icon indicating copy to clipboard operation
split-it-easy-android copied to clipboard

Data loss on double screen rotation

Open davirec opened this issue 2 years ago • 0 comments

In the double screen rotation test to detect data loss, an application failure was identified:

GroupListActivity: element test123 loses state

Before and after double screen rotation

HandleOnGroupClickActivity: menu disappears

Before and after double screen rotation

MainActivity: content_description': u'Close navigation drawer' content_description': u'Open navigation drawer'

TouchEvent [[0,54],[98,152]] TouchEvent [[53,650],[667,964]] Cap01: capture screen properties before rotation DoubleRotationEvent Cap02: capture screen properties after rotation 

Cap01 != Cap02 (incompatible sizes)

A data loss problem occurs when data is accidentally deleted or state variables are accidentally assigned with default or initial values. This issue is related to the activity's lifecycle (1). When a screen rotation occurs, the activity is destroyed and resumed. Data loss will happen if the developer does not save the variables before the destruction and restore them after creation. To avoid this, the developers have to implement both the logic necessary to save the activity state in the onSaveInstanceState() callback method and the logic to resume its state in the onRestoreInstanceState() callback method. Another way to avoid data loss problems is to use the view model, designed to store and manage UI-related data in a lifecycle-conscious way (2).

Note:

  • Double screen rotation: It is executed twice to reach a state that should be exactly the same as the screen before if no data loss occurred.
  • A data loss problem occurs when data is accidentally deleted or state variables are accidentally assigned with default or initial values.
  1. https://developer.android.com/guide/components/activities/activity-lifecycle
  2. https://developer.android.com/topic/libraries/architecture/viewmodel

davirec avatar Mar 24 '22 17:03 davirec