Hi,
Recently I found OneShotPreDrawListener class in android framework which looks for me like a solution which covers all the cornercases like removing the view from the hierarchy before the first drawing:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/com/android/internal/view/OneShotPreDrawListener.java
Don't you think View.doOnPreDraw(...) should use analog of it internally(with addOnAttachStateChangeListener)?