title: JNI Error on Scene Transition Animation - Layer exceeds max
body: <p><strong>please notice the EDIT in the bottom of the question</strong></p>
  
  <p>I have 2 activities: <code>ActivityA</code>, <code>ActivityB</code> with associated frgments: <code>FragmentA</code>, <code>FragmentB</code>  respectively. <code>ImageView v</code> is shared between those two fragments.</p>
  
  <p>some Code: <em>ActivityA</em></p>
  
  <pre><code>Intent intent = new Intent(this, ActivityB.class);
  final ActivityOptionsCompat activityOptionsCompat = ActivityOptionsCompat.
                           makeSceneTransitionAnimation(this, imageView, "photo");   
  
  ActivityCompat.startActivity(this, intent, activityOptionsCompat.toBundle());
  </code></pre>
  
  <p><em>ActivityB</em></p>
  
  <pre><code>FragmentB fragment = new FragmentB();
  getFragmentManager().beginTransaction()..replace(R.id.fragment_container, fragment, TAG).addToBackStack(TAG).commit();
  </code></pre>
  
  <p><em>FragmentB</em></p>
  
  <pre><code>mView = (ImageView) view.findViewById(R.id.view);
  ViewCompat.setTransitionName(mView, "photo);
  </code></pre>
  
  <p>4 out of 5 times it's working. but when it's not working i'm getting the <strong>Very informative</strong> error:</p>
  
  <pre><code>W/OpenGLRenderer﹕ Layer exceeds max. dimensions supported by the GPU (1080x10659, max=4096x4096)
  JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception 'java.lang.IllegalStateException' thrown in void android.os.MessageQueue.nativePollOnce(long, int):-2
  </code></pre>
  
  <p>Call to <code>Picasso</code></p>
  
  <pre><code>Picasso.with(context).load(url).centerCrop().resize(width, height).noFade().into(mView);
  </code></pre>
  
  <p><em>Few things that can cause this:</em></p>
  
  <ol>
  <li><p>in <code>FragmentB</code> <code>mView</code> position is calculated dynamically using <code>ViewTreeObserver.OnGlobalLayoutListener</code></p></li>
  <li><p><code>mView</code> extends <code>ImageView</code> in order to create Oval effect in both of the Fragments.</p></li>
  <li>the root <code>ViewGroup</code> is a <code>ScrollView</code></li>
  </ol>
  
  <p>one last thing: the <code>Theme</code> of both of the activities is a child of </p>
  
  <pre><code>&lt;style name="Theme" parent="Theme.AppCompat.Light"
      &lt;item name="android:windowContentTransitions"&gt;true&lt;/item&gt;
      &lt;item name="android:windowAllowEnterTransitionOverlap"&gt;true&lt;/item&gt;
      &lt;item name="android:windowAllowReturnTransitionOverlap"&gt;true&lt;/item&gt;
      &lt;item name="android:windowSharedElementEnterTransition"&gt;@android:transition/move&lt;/item&gt;
      &lt;item name="android:windowSharedElementExitTransition"&gt;@android:transition/move&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p><strong>--- EDIT ---</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/26664922/crash-material-design-android-5-0/27906489">Similar question and answer to my problem</a>
  <a href="https://stackoverflow.com/questions/26626344/scene-transition-with-hero-elements-throws-layer-exceeds-max-dimensions-support">and another</a></p>
  
  <p>Answer do solve the issue but only for <em>API 21</em>. I'm using <code>ActivityCompat.startActivity(...)</code>. it supports <em>api 16</em> and above <strong>but</strong> <code>TransitionListener</code> is only available since <em>API 19</em> and supports <code>SceneTransition</code> since <em>API 21</em></p>
  
  <p>Also <code>android:transitionGroup="true"</code> requires <code>API 21</code> so now i have <strong>2 main questions:</strong></p>
  
  <ol>
  <li>Why i'm even getting <code>LayerExceeds max</code> error? my shared <code>View</code> is no bigger than 1080x1080. </li>
  <li>how can i handle this kind of error on <em>API &lt; 21</em> where both <code>TransitionListener</code> and <code>transitionGroup</code> are unavailable?</li>
  </ol>
  
  <p><strong>ERROR stacktrace</strong></p>
  
  <pre><code>JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception 'java.lang.IllegalStateException' thrown in void android.os.MessageQueue.nativePollOnce(long, int):-2
  in call to CallVoidMethodV
  art/runtime/check_jni.cc:65] from void android.os.MessageQueue.nativePollOnce(long, int)
  art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
  art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x72fb6000 self=0xb4827800
  art/runtime/check_jni.cc:65]   | sysTid=6497 nice=0 cgrp=default sched=0/0 handle=0xb6f83bec
  art/runtime/check_jni.cc:65]   | state=R schedstat=( 1181860917 459124594 2277 ) utm=100 stm=18 core=2 HZ=100
  art/runtime/check_jni.cc:65]   | stack=0xbe27d000-0xbe27f000 stackSize=8MB
  art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
  art/runtime/check_jni.cc:65]   native: #00 pc 00004e64  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
  art/runtime/check_jni.cc:65]   native: #01 pc 00003665  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
  art/runtime/check_jni.cc:65]   native: #02 pc 00256429  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, int, char const*, art::mirror::ArtMethod*)+84)
  art/runtime/check_jni.cc:65]   native: #03 pc 00238fe7  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) const+158)
  art/runtime/check_jni.cc:65]   native: #04 pc 000b191b  /system/lib/libart.so (art::JniAbort(char const*, char const*)+610)
  art/runtime/check_jni.cc:65]   native: #05 pc 000b2055  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
  art/runtime/check_jni.cc:65]   native: #06 pc 000b530f  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1346)
  art/runtime/check_jni.cc:65]   native: #07 pc 000bd6f7  /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+42)
  art/runtime/check_jni.cc:65]   native: #08 pc 0006244b  /system/lib/libandroid_runtime.so (???)
  art/runtime/check_jni.cc:65]   native: #09 pc 000760c5  /system/lib/libandroid_runtime.so (android::NativeDisplayEventReceiver::dispatchVsync(long long, int, unsigned int)+40)
  native: #10 pc 0007628d  /system/lib/libandroid_runtime.so (android::NativeDisplayEventReceiver::handleEvent(int, int, void*)+80)
  native: #11 pc 00012545  /system/lib/libutils.so (android::Looper::pollInner(int)+484)
  native: #12 pc 000125ed  /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92)
  native: #13 pc 00081709  /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
  native: #14 pc 000b3863  /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+102)
  at android.os.MessageQueue.nativePollOnce(Native method)
  at android.os.MessageQueue.next(MessageQueue.java:143)
  at android.os.Looper.loop(Looper.java:122)
  at android.app.ActivityThread.main(ActivityThread.java:5254)
  at java.lang.reflect.Method.invoke!(Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  Fatal signal 11 (SIGSEGV), code 1, fault addr 0xfffffff0 in tid 6497 
  </code></pre>