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

Connected but window is invisible. #2444

Open
2 tasks done
mikaelfrykholm opened this issue Jul 1, 2021 · 7 comments
Open
2 tasks done

Connected but window is invisible. #2444

mikaelfrykholm opened this issue Jul 1, 2021 · 7 comments

Comments

@mikaelfrykholm
Copy link

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Debian 11 with Wayland
  • scrcpy version:1.17
  • installation method: apt
  • device model:
  • Android version: unknown ReDroid (Android 11)

Describe the bug
Unable to get a display window from scrcpy without forcing a window size.
The command below works.

mikael@ronin ~ [1]> scrcpy --window-width 1280 --window-height 768 -V debug
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
DEBUG: Using server: /usr/share/scrcpy/scrcpy-server
/usr/share/scrcpy/scrcpy-server: 1 file pushed. 51.8 MB/s (34015 bytes in 0.001s)
[server] INFO: Device: unknown ReDroid (Android 11)
DEBUG: Screensaver enabled
DEBUG: Starting stream thread
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 20.3.4
INFO: Trilinear filtering enabled
INFO: Initial texture: 720x1280
[server] DEBUG: Using encoder: 'OMX.google.h264.encoder'
Failed to create //.cache for shader cache (Permission denied)---disabling.

Please do not post screenshots of your terminal, just post the content as text instead.

@rom1v
Copy link
Collaborator

rom1v commented Jul 1, 2021

Unable to get a display window from scrcpy without forcing a window size.

I'm pretty sure this is unrelated, the window dimensions (--window-width and --window-height) are just used locally to set the initial size, they don't affect the time when the window is shown (on the first received frame).

@mikaelfrykholm
Copy link
Author

I get a window that is invisible, there is an icon in gnome-shell and I can move it to another workspace with hotkeys. Perhaps a difference between wayland and X?

@plevart
Copy link

plevart commented Nov 26, 2023

Hi, let me comment on this issue.... I'm on Fedora 38 (KDE) with Wayland and experiencing similar symptoms.
Whenever scrcpy is launched, it seems like it does not open a window. But observing closely, I noticed a barely visible 1-pixel-wide, ~ 30-pixels-high vertical line in the center of the screen. It is a window, shrunk to sub-zero dimensions so that even the title bar is invisible. I can resize it with the mouse though. In my case adding --window-width and --window-height options does not help. The initial window is still fully shrunk.

Here's what gets printed in such session on the command line:

[peter@sun ~]$ scrcpy --window-width=500 --window-height=400
scrcpy 2.3 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  33251FDH20088J                  device  Pixel_7
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 175.6 MB/s (65851 bytes in 0.000s)
[server] INFO: Device: [Google] google Pixel 7 (Android 14)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 23.1.9
INFO: Trilinear filtering enabled
INFO: Texture: 1080x2400

@rhnvrm
Copy link

rhnvrm commented Dec 8, 2023

Hi, I'm on a similar setup like @plevart. I am using Fedora 38 (KDE) with Wayland and having the same issue. I tried the following as of now:

Please let me know if I can help gather any further info to debug this.

P.S. as a workaround, I am using the flatpak for guiscrcpy, which seems to work fine for my machine. flatpak install flathub in.srev.guiscrcpy. But it would be great to be able to use scrcpy directly.

@rom1v
Copy link
Collaborator

rom1v commented Dec 8, 2023

Currently, the window is created hidden with size 0x0:

scrcpy/app/src/screen.c

Lines 399 to 400 in c6ff78f

screen->window =
SDL_CreateWindow(params->window_title, 0, 0, 0, 0, window_flags);

And resized+shown when the first frame is received:

sc_screen_show_initial_window(struct sc_screen *screen) {

Your problem could be probably reproduced with a minimal app doing the same with just SDL. If so, that will allow to report the problem to SDL.

@rhnvrm
Copy link

rhnvrm commented Dec 8, 2023

Wrote a minimal SDL app (used ChatGPT for this as I'm not an expert)

The window seems to open up.

image

Here is the code:

#include <SDL.h>
#include <stdbool.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
        return 1;
    }

    SDL_Window *window = SDL_CreateWindow("Test Window",
                                          SDL_WINDOWPOS_UNDEFINED,
                                          SDL_WINDOWPOS_UNDEFINED,
                                          0, 0,
                                          SDL_WINDOW_HIDDEN);

    if (!window) {
        SDL_Log("Unable to create window: %s", SDL_GetError());
        SDL_Quit();
        return 1;
    }
    printf("Window created with size 0x0 and hidden\n");

    SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
    if (!renderer) {
        SDL_Log("Unable to create renderer: %s", SDL_GetError());
        SDL_DestroyWindow(window);
        SDL_Quit();
        return 1;
    }

    bool running = true;
    bool window_shown = false;
    Uint32 start_time = SDL_GetTicks();

    while (running) {
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                running = false;
            }
        }

        Uint32 elapsed_time = SDL_GetTicks() - start_time;
        if (!window_shown && elapsed_time >= 3000) {
            SDL_SetWindowSize(window, 800, 600);
            printf("Window resized to 800x600\n");
            SDL_ShowWindow(window);
            printf("Window shown\n");
            window_shown = true;
        }

        SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
        SDL_RenderClear(renderer);
        SDL_RenderPresent(renderer);
    }

    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}

@rom1v
Copy link
Collaborator

rom1v commented Dec 8, 2023

What if you set the position before the size (like scrcpy does)?

Maybe there is a race condition, what if you don't wait 3 seconds before showing the window?

Could add print logs to check the actual values passed to:

sc_screen_show_initial_window(struct sc_screen *screen) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants