fix: crash when the icon surface view still has a parent on resume (#7513)
LawnchairFloatingSurfaceView.removeViewImmediate() skipped the removal when isAttachedToWindow was false. onNewIntent is delivered inside performResumeActivity, while the window can still be re-attaching: the view is already a child of the drag layer but not attached yet. The removal was skipped, so the following show() crashed on addView() with IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. FloatingSurfaceView removes the view unconditionally, and removeViewInLayout() is a no-op when the view has no parent, so match it. Co-authored-by: caizhixing <caizhixing@users.noreply.github.com>
This commit is contained in:
1 parent
34d1c3ef88
commit
d180feb55f
1 file changed
+6
-3
@@ -104,9 +104,12 @@ class LawnchairFloatingSurfaceView @JvmOverloads constructor(
|
||||
private fun removeViewImmediate() {
|
||||
// Cancel any pending remove
|
||||
Executors.MAIN_EXECUTOR.handler.removeCallbacks(mRemoveViewRunnable)
|
||||
if (isAttachedToWindow) {
|
||||
removeViewFromParent()
|
||||
}
|
||||
// Remove unconditionally, matching FloatingSurfaceView. isAttachedToWindow can be false
|
||||
// while the view is still a child of the drag layer: onNewIntent is delivered inside
|
||||
// performResumeActivity, when the window may still be re-attaching. Skipping the removal
|
||||
// in that window leaves the view with a parent, and the next show() crashes on addView
|
||||
// with "The specified child already has a parent".
|
||||
removeViewFromParent()
|
||||
}
|
||||
|
||||
override fun isOfType(type: Int): Boolean {
|
||||
|
||||
Reference in new issue
Block a user