Does the race state in performTraversals and onConfigurationChanged lead to a bad layout?

I have a rather complicated Android app where I process rotation myself through onConfigurationChanged, and not restart activity. After using the device or emulator for some time (many turns), I begin to see that the application does not work out correctly with interruptions (it preserves the width of the portrait in landscape mode)

I have added trace logging instructions to all the "onAction" events in the activity, and I see two different threads:

Correctly:

  • onConfigurationChanged
  • onMeasure (with old width)
  • Onlayout
  • onMeasure (with new width)
  • onSizeChanged
  • Onlayout
  • Ondraw

When the layout is wrong, I see this stream

Wrong:

  1. onMeasure (with new width)
  2. onSizeChanged
  3. Onlayout
  4. Ondraw
  5. onConfigurationChanged
  6. onMeasure (with new width)
  7. Onlayout
  8. Ondraw

, , : 3 , :

  • MessageType 1003 → mWinFrame
  • MessageType 1000 → / ( mWinFrame)
  • MessageType 118 → , onConfigurationChanged.

, 118, 1003, 1000. , 1003, 1000, 118, , onConfigurationChanged.

, , , , , , / onPreDraw.

:

1) , onConfigurationChanged , , ?

2) ? , , / " ".

+3
1

, -, , - kludge... setVisible (false) onPause() Runnable, setVisible (true) onResume().

/, , , , , , , , .

0

Source: https://habr.com/ru/post/1753727/


All Articles