Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOSP commonization: removing seemingly redundant drag cancellation for iOS magnifier #1713

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.PointerInputScope
import androidx.compose.ui.util.fastAny
import kotlin.coroutines.cancellation.CancellationException
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -77,13 +76,6 @@ internal suspend fun PointerInputScope.detectDownAndDragGesturesWithObserver(
coroutineScope {
launch(start = CoroutineStart.UNDISPATCHED) { detectPreDragGesturesWithObserver(observer) }
launch(start = CoroutineStart.UNDISPATCHED) { detectDragGesturesWithObserver(observer) }
.invokeOnCompletion {
// Otherwise observer won't be notified if
// composable was disposed before the drag cancellation
if (it is CancellationException){
observer.onCancel()
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,7 @@ internal class TextFieldSelectionManager(val undoManager: UndoManager? = null) {
updateFloatingToolbar(show = true)
}

override fun onCancel() {
draggingHandle = null
Copy link
Collaborator

@ASalavei ASalavei Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks reasonable (The same happened in onStop()).
Could you please elaborate, what fixes this removal?

Copy link
Author

@mazunin-v-jb mazunin-v-jb Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does look reasonable indeed.
My point here is that we should upstream this to AOSP, and the AOSP doesn't have these lines and doesn't have the stuck magnifier bug. It was assumed in the magnifier PR that this issue couldn't be reproduced on Android because the reproduction steps couldn't be replicated there, which turned out to be incorrect.
So I have tested that on physical iOS and Android devices, and I couldn't reproduce the issue without these lines.
Although I remember that bug too, I think we can remove these lines if we can't reproduce it now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we upstream these lines to be on the safe side?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or instead we can write some test in AOSP to make sure that we won't have regression here

currentDragPosition = null
}
override fun onCancel() {}
}

/** [TextDragObserver] for dragging the cursor to change the selection in TextField. */
Expand Down