-
Notifications
You must be signed in to change notification settings - Fork 181
Fix FloatingX control operations timing issue by implementing operation queuing for all control methods #230
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
base: main
Are you sure you want to change the base?
Conversation
|
@Petterpx 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: Petterpx <41142188+Petterpx@users.noreply.github.com>
Co-authored-by: Petterpx <41142188+Petterpx@users.noreply.github.com>
|
@copilot updateViewContent() 是不是忘了考虑了 |
Co-authored-by: Petterpx <41142188+Petterpx@users.noreply.github.com>
You're absolutely right! I added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
FloatingX control operations called in
Activity.onCreate()were being silently ignored due to lifecycle timing issues. The floating window's internal view hadn't been initialized yet when these operations were called, causing them to fail.Problem
When calling
FloatingX.control().xxxoperations inonCreate(), several issues occurred:Root Cause
Operations like
move(),show(),hide(), andupdateViewContent()depend on the floating window's internal view being created and attached. However, when called inonCreate(), the Activity lifecycle callbacks that initialize the floating window haven't been triggered yet, resulting ininternalViewbeing null and operations being silently ignored.Solution
Implemented a comprehensive operation queuing mechanism that:
Key Changes
FxQueuedOperation.kt: New sealed class for operation types (Show, Hide, Move, MoveByVector, UpdateViewContent)FxBasisControlImp.kt: Added thread-safe operation queuing withexecutePendingOperations()for all affected methodsFxAppPlatformProvider.kt: Triggers pending operation execution after app-level floating window initializationFxSystemPlatformProvider.kt: Triggers pending operation execution after system-level floating window initializationAffected Operations
All control operations that depend on the floating window being ready are now queued:
show()- Queued when internal view not readyhide()- Queued when internal view not readymove()/moveByVector()- Queued when internal view not readyupdateViewContent()- Queued when viewHolder not readyResult
Backward Compatibility
Testing
Added comprehensive test activities:
TestLifecycleActivity.kt- Demonstrates the fix for the original issue includingupdateViewContent()EdgeCaseTestActivity.kt- Tests rapid operations, duplicates, cancellation, etc.Fixes #195.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.