commit 69a271f3330f24beef9d6119dff569d083e9baeb
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Oct 25 13:36:07 2021 +0200

    Fix for a rare crash.

diff --git a/src/main/java/org/distorted/screens/RubikScreenPlay.java b/src/main/java/org/distorted/screens/RubikScreenPlay.java
index 5f8ce8ff..8f74fa25 100644
--- a/src/main/java/org/distorted/screens/RubikScreenPlay.java
+++ b/src/main/java/org/distorted/screens/RubikScreenPlay.java
@@ -480,22 +480,30 @@ public class RubikScreenPlay extends RubikScreenBase
       isFullScreen = true;
       }
 
-    // if on Android 11 or we are fullscreen
-    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || isFullScreen )
+    try
       {
-      window.showAsDropDown(view, xoff, yoff, Gravity.CENTER);
-      window.update(view, w, h);
+      // if on Android 11 or we are fullscreen
+      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || isFullScreen )
+        {
+        window.showAsDropDown(view, xoff, yoff, Gravity.CENTER);
+        window.update(view, w, h);
+        }
+      else  // Android 10 or below in pop-up mode or split-screen mode
+        {
+        view.getLocationOnScreen(mLocation);
+        int width  = view.getWidth();
+        int height = view.getHeight();
+        int x = mLocation[0]+(width-w)/2;
+        int y = mLocation[1]+height+yoff;
+
+        window.showAsDropDown(view);
+        window.update(x,y,w,h);
+        }
       }
-    else  // Android 10 or below in pop-up mode or split-screen mode
+    catch( IllegalArgumentException iae )
       {
-      view.getLocationOnScreen(mLocation);
-      int width  = view.getWidth();
-      int height = view.getHeight();
-      int x = mLocation[0]+(width-w)/2;
-      int y = mLocation[1]+height+yoff;
-
-      window.showAsDropDown(view);
-      window.update(x,y,w,h);
+      // ignore, this means window is 'not attached to window manager' -
+      // which most probably is because we are already exiting the app.
       }
     }
 
