4

I have an app that ran just fine on KitKat but when upgrading my phone to API21 (Lollipop), I'm getting this strange failure. I'm thinking it's a google bug, but wanted to know if anyone else had seen it and found a workaround? I'm performing the following simple piece of code (my class extends SupportMapFragment, fyi):

public CameraPosition getCurrentCameraPosition() {
    return mMap != null ? mMap.getCameraPosition() : null;
}

Yet the mMap.getCameraPosition() is causing this exception:

11-21 16:39:34.844: E/art(12895): Throwing OutOfMemoryError "java.lang.String[] of length 1098697933 would overflow"
11-21 16:39:34.844: D/AndroidRuntime(12895): Shutting down VM
11-21 16:39:34.844: E/AndroidRuntime(12895): FATAL EXCEPTION: main
11-21 16:39:34.844: E/AndroidRuntime(12895): Process: com.SNIP.android.client, PID: 12895
11-21 16:39:34.844: E/AndroidRuntime(12895): java.lang.OutOfMemoryError: java.lang.String[] of length 1098697933 would overflow
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.Parcel.readStringArray(Parcel.java:1792)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.StrictMode$ViolationInfo.<init>(StrictMode.java:2200)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1738)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.Parcel.readExceptionCode(Parcel.java:1521)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.Parcel.readException(Parcel.java:1490)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.getCameraPosition(Unknown Source)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at com.google.android.gms.maps.GoogleMap.getCameraPosition(Unknown Source)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at com.SNIP.android.client.fragments.CLASS2.getCurrentCameraPosition(CLASS2.java:170)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at com.SNIP.android.client.fragments.CLASS1.onCreateView(CLASS1.java:684)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.Handler.handleCallback(Handler.java:739)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.Handler.dispatchMessage(Handler.java:95)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.os.Looper.loop(Looper.java:135)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at android.app.ActivityThread.main(ActivityThread.java:5221)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at java.lang.reflect.Method.invoke(Native Method)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at java.lang.reflect.Method.invoke(Method.java:372)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
11-21 16:39:34.844: E/AndroidRuntime(12895):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

And in case you're wondering why I'm using a member variable to reference the GoogleMap instead of getMap().... I was using getMap() here but after the upgrade to Lollipop, that started returning null (despite it returning a proper GoogleMap in onCreateView).

I'm now guessing it was returning null because it ran into this OutOfMemoryException, caught it in a catch block, and returned null.

1
  • 1
    After doing some more investigation, this is related to enabling StrictMode. It appears google has a problem unparceling data when constructing a ViolationInfo object for a StrictMode violation (this did not happen in the same code prior to Lollipop). The final readStringArray is trying to read 1GB of data. To me it sounds like an unintialized variable. But my workaround for now is to just not use StrictMode. If you're interested, it's happening at line 2200 in the following: android.googlesource.com/platform/frameworks/base/+/master/core/…
    – pdub
    Commented Nov 22, 2014 at 3:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.