Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App relies on onRetainNonConfigurationInstance() always being called #5

Open
dglynch opened this issue Mar 26, 2016 · 0 comments
Open

Comments

@dglynch
Copy link

dglynch commented Mar 26, 2016

In PaintActivity, the app relies on onRetainNonConfigurationInstance() to store important state information that cannot otherwise be recovered in the event of activity death. According to the Android SDK documentation, this method is not always guaranteed to be called, and should not be relied upon as anything other than an optimization:

http://developer.android.com/reference/android/app/Activity.html#onRetainNonConfigurationInstance()

Contrary to this, the app relies on this method always being called in order to function correctly in basic use-cases.

Whenever this method is not called by the platform (which seems to be the case when the "Don't keep activities" developer option is ticked), the following two consistent user-visible behaviours appear:

  • Whenever the user uses StartNewActivity to select a new outline, the app crashes. This is a minor inconvenience to users, but it does require them to always only colour a randomly selected outline.
  • Whenever the user uses PickColorActivity to select a new colour, the outline is re-randomized and all colouring data is reset to blank. This is a major inconvenience to users because it means colour-selection can only be done before starting to draw, and cannot be informed by knowledge of which outline is about to be coloured.

Here is a stack-trace showing the crash mentioned above:

03-26 14:50:31.335 2003-4091/? I/ActivityManager: START u0 {act=org.androidsoft.coloring.paint.START_NEW cmp=org.androidsoft.coloring/.ui.activity.StartNewActivity} from uid 10036 on display 0
03-26 14:50:31.421 2760-2760/? I/Keyboard.Facilitator: onFinishInput()
03-26 14:50:31.446 2003-2021/? I/ActivityManager: Displayed org.androidsoft.coloring/.ui.activity.StartNewActivity: +104ms
03-26 14:50:31.475 29609-29637/? D/OpenGLRenderer: endAllStagingAnimators on 0xb447d900 (RippleDrawable) with handle 0xab212250
03-26 14:50:33.240 2003-2346/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 362]
03-26 14:50:35.062 29609-29692/? E/AndroidRuntime: FATAL EXCEPTION: Thread-10762
                                                   Process: org.androidsoft.coloring, PID: 29609
                                                   java.lang.IllegalArgumentException: width and height must be > 0
                                                       at android.graphics.Bitmap.createBitmap(Bitmap.java:829)
                                                       at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
                                                       at android.graphics.Bitmap.createBitmap(Bitmap.java:775)
                                                       at org.androidsoft.coloring.ui.widget.PaintView.loadFromBitmap(PaintView.java:98)
                                                       at org.androidsoft.coloring.ui.activity.PaintActivity$InitPaintView.run(PaintActivity.java:371)
                                                       at java.lang.Thread.run(Thread.java:818)
03-26 14:50:35.065 2003-16076/? W/ActivityManager:   Force finishing activity org.androidsoft.coloring/.ui.activity.PaintActivity

I think it would be wise to implement some other more reliable means to persist outline-selection and colouring data when navigating between these three activities. While this bug is only easily reproducible when certain developer-only options are set, there is still a chance it may randomly affect an ordinary user, especially if future versions of Android ever reduce the probability of this non-guaranteed call (which is already deprecated as of API level 13). And it will definitely impact users who are handed a developer device and don't know how to (or know they need to) disable the "Don't keep activities" option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant