scrcpy: Bug: ScrCpy either steals focus or closes itself completely when orientation changes and it has no focus

  • [V ] I have read the FAQ.
  • [V ] I have searched in existing issues.

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) :

2023-04-25_00-42-13_1.zip

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15

Commits related to this issue

Most upvoted comments