code: private void logIsShownCheckFailure(View view) {
      try {
        SelendroidLogger.debug("Display check failed because View.isShown() == false");
        View current = view;
        do {
          if ((current.getVisibility()) != View.VISIBLE) {
            SelendroidLogger.debug(String.format(
                "isShown: View %s is not visible because its ancestor %s has visibility %d",
                view, current, current.getVisibility()));
            break;
          }
          ViewParent parent = current.getParent();
          if (parent == null) {
            SelendroidLogger.debug(String.format(
                "isShown: View %s is not visible because its ancestor %s has no parent " +
                    "(it is not attached to view root): ",
                view, current));
            break;
          }
          if (!(parent instanceof View)) {
            // The only case where View.isShown() returns true:
            // The view needs to have an ancestor that is not a View and all ancestors on the way up have to
            // be visible.
            break;
          }
          current = (View) parent;
        } while (current != null);
        SelendroidLogger.debug(String.format("View %s is not visible", view));
      } catch (Exception e) {
        // Don't let an exception in debug printing crash the caller
        SelendroidLogger.error("isShown() debug printing failed", e);
      }
    }
docs: If view.isShown() == false, logs why exactly this evaluates to false.
  Copied from Android's implementation of View.isShown().