scrcpy: Bug: ScrCpy either steals focus or closes itself completely when orientation changes and it has no focus
Environment
-
OS: [e.g. Debian, Windows, macOS…] Windows
-
scrcpy version: [e.g. 1.12.1] 2.0
-
installation method: [e.g. manual build, apt, snap, brew, Windows release…] Extract from the ZIP file
-
device model: Pixel 6
-
Android version: [e.g. 10] 13
Describe the bug I’ve launched an app that decided to change the device orientation after some time. During this time, I was actually using a very different window on Windows OS. When it changed the orientation, ScrCpy stole focus. As it was in a full screen online game, it was very annoying because I lost the context and had to quickly switch back. When I tried to reproduce it via a sample, I’ve also noticed that if ScrCpy is just minimized to the taskbar, it will close itself completely when the orientation changes. The command I use for ScrCpy is:
C:\android\scrcpy\scrcpy-noconsole.vbs -S --always-on-top --stay-awake --no-audio
Here’s a sample app to simulate this, which changes the orientation after 5 seconds since shown. During this time, switch to another window, and wait for it to happen.
My Application.zip app-debug.zip
Code:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Handler(mainLooper).postDelayed({
requestedOrientation = if (resources.configuration.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
else
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}, 5000L)
}
}
On errors, please provide the output of the console (and adb logcat
if relevant).
There are no errors.
However, here’s a video showing the issue: 2023-04-25_00-34-32.zip
And here’s a video showing the issue when there is another window, on top, that needs to stay on focus (a video player app) :
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15
Commits related to this issue
- Accept texture failures When the scrcpy window is minimized on Windows with D3D9, texture creation and update fail. In that case, do not terminate scrcpy, but store the pending size or frame to upda... — committed to Genymobile/scrcpy by rom1v a year ago
- Delay window resize when minimized On some window managers (e.g. on Windows), performing a resize while the window is minimized does nothing (the restored window keeps its old size). Therefore, like... — committed to Genymobile/scrcpy by rom1v a year ago
- Accept texture failures When the scrcpy window is minimized on Windows with D3D9, texture creation and update fail. In that case, do not terminate scrcpy, but store the pending size or frame to upda... — committed to Genymobile/scrcpy by rom1v a year ago
- Delay window resize when minimized On some window managers (e.g. on Windows), performing a resize while the window is minimized does nothing (the restored window keeps its old size). Therefore, like... — committed to Genymobile/scrcpy by rom1v a year ago
- Accept texture failures When the scrcpy window is minimized on Windows with D3D9, texture creation and update fail. In that case, do not terminate scrcpy. Instead, store the pending size or frame to... — committed to Genymobile/scrcpy by rom1v a year ago
- Delay window resize when minimized On some window managers (e.g. on Windows), performing a resize while the window is minimized does nothing (the restored window keeps its old size). Therefore, like... — committed to Genymobile/scrcpy by rom1v a year ago
@rom1v OK here: https://github.com/Genymobile/scrcpy/issues/4109