Fatal Exception: java.lang.StackOverflowError stack size 8MB android.view.View.hasIdentityMatrix : <p>This is a very rare bug that's happening in my app. Users open <code>SettingsActivity</code> and notice the app has frozen, after which it crashes (5 - 10s later?).<br>
I have no idea how to proceed, I've tried debugging but can't reproduce the issue. I've seen other similar questions, but their stack traces had application methods that were the cause of an infinite loop. Here, there is no application code that's responsible (at least, the stack trace doesn't reveal anything)</p>

<p>Stack trace shows only a bunch of Android core library methods (<code>View</code>, <code>ViewGroup</code>, <code>RecyclerView</code>), and has something to do with accessibility.</p>

<p>This perplexes me, since:</p>

<ul>
<li>I'm not using RecyclerView anywhere in <code>SettingsActivity</code>, <code>SettingsFragment</code>, or their layouts</li>
<li>The only place I am using it, works perfectly, as proven by a few screenshots and videos users have sent me</li>
<li>I haven't overriden any accessibility callbacks in any of my activities</li>
<li>I added breakpoints in every method the stack trace shows, but those breakpoints were never hit. In any activity. (<strong>wtf</strong>)</li>
</ul>

<p>Considering the stack trace doesn't show any custom classes/methods part of my codebase, how am I supposed to proceed? Is this a known bug in <code>androidx.recyclerview</code>, for example?</p>

<p>I know for sure that the app crashes in <code>SettingsActivity</code>, since Firebase tracks activities in Crashlytics for you. (the flow was <code>MainActivity -&gt; [AnyActivity] -&gt; SettingsActivity -&gt; &lt;freeze&gt; -&gt; &lt;crash&gt;</code>).</p>

<p>Our entire team can't reproduce this issue (using the same exact Play Store version), but it seems like there are around 100 users that are experiencing this crash. All devices that show these fatal exceptions are being used by our team to debug, to no avail.</p>

<h3>Stack trace</h3>

<pre><code>Fatal Exception: java.lang.StackOverflowError: stack size 8MB
       at android.view.View.hasIdentityMatrix (View.java:14669)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6138)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
       at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6121)
       at android.view.View.getGlobalVisibleRect (View.java:16064)
       at android.view.View.isVisibleToUser (View.java:9065)
       at android.view.View.isVisibleToUser (View.java:9023)
       at android.view.View.onInitializeAccessibilityNodeInfoInternal (View.java:8814)
       at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal (ViewGroup.java:3642)
       at android.view.View$AccessibilityDelegate.onInitializeAccessibilityNodeInfo (View.java:27387)
       at androidx.core.view.AccessibilityDelegateCompat.onInitializeAccessibilityNodeInfo (AccessibilityDelegateCompat.java:275)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:124)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
       at androidx.core.view.AccessibilityDelegateCompat$AccessibilityDelegateAdapter.onInitializeAccessibilityNodeInfo (AccessibilityDelegateCompat.java:86)
       at android.view.View.onInitializeAccessibilityNodeInfo (View.java:7776)
       at android.view.View.createAccessibilityNodeInfoInternal (View.java:7737)
       at android.view.View$AccessibilityDelegate.createAccessibilityNodeInfo (View.java:27485)
       at android.view.View.createAccessibilityNodeInfo (View.java:7720)
       at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode (AccessibilityInteractionController.java:1147)
       at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos (AccessibilityInteractionController.java:972)
       at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread (AccessibilityInteractionController.java:336)
       at android.view.AccessibilityInteractionController.access$400 (AccessibilityInteractionController.java:67)
       at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage (AccessibilityInteractionController.java:1324)
       at android.os.Handler.dispatchMessage (Handler.java:106)
       at android.os.Looper.loop (Looper.java:193)
       at android.app.ActivityThread.main (ActivityThread.java:6898)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:537)
       at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
</code></pre>

<h3>SettingsActivity</h3>

<pre class="lang-java prettyprint-override"><code>public class SettingsActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);

        settingsFragment = new SettingsFragment();

        getSupportFragmentManager().beginTransaction()
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                .replace(R.id.settings_container, settingsFragment, "Settings")
                .commit();

        ... // also contains code to init an IAP helper,
            // but that doesn't use RecyclerView either (obviously)

}
</code></pre>

<h3>SettingsFragment</h3>

<pre class="lang-java prettyprint-override"><code>public class SettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener {
    @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        ...
        addPreferencesFromResource(R.xml.preferences);
        ...
}
</code></pre>
