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

[BUG] Screen is flipped vertically when streaming from Android device #597

Closed
burakkaraceylan opened this issue Nov 26, 2021 · 10 comments · Fixed by Unity-Technologies/com.unity.webrtc#594
Assignees
Labels
bug Something isn't working issued This means the ticket is already created on internal issue tracker waiting for release This issue is already fixed and will be contained in next version
Milestone

Comments

@burakkaraceylan
Copy link

Stream broadcasted from an Android device is shown vertically flipped on the web applicaton.
To Reproduce
Steps to reproduce the behavior:

  1. Build and run broadcast sample on Android device
  2. Go to receiver sample on the web app
  3. Click play
  4. See error

Expected behavior
Stream should be shown exactly as it is on the android application

Screenshots
image

Environment (please complete the following information):

  • OS: Android 11
  • Browser: Chrome
  • Unity Version: 2020.3.21f1
  • Package version [e.g. 3.1.0-exp2]
@burakkaraceylan burakkaraceylan added the bug Something isn't working label Nov 26, 2021
@karasusan
Copy link
Collaborator

@burakkaraceylan
Thanks for the feedback.
There is a workaround that change graphics API to Vulkan.

@burakkaraceylan
Copy link
Author

burakkaraceylan commented Nov 27, 2021

Is that possible? As far as I know you can't compile AR core when vulkan is enabled.

@karasusan
Copy link
Collaborator

memo: WRS-166

@karasusan karasusan modified the milestones: 3.1.0-exp.2, 3.1.0-exp.3 Nov 30, 2021
@karasusan karasusan added the issued This means the ticket is already created on internal issue tracker label Nov 30, 2021
@karasusan
Copy link
Collaborator

@burakkaraceylan
Unfortunately, AR core is needed to build GLES graphic API.

There is a workaround that customizing ScreenStreamSender using another constructor of VideoStreamTrack.
https://github.com/Unity-Technologies/com.unity.webrtc/blob/develop/Runtime/Scripts/VideoStreamTrack.cs#L113-L119

@burakkaraceylan
Copy link
Author

burakkaraceylan commented Dec 7, 2021

For now I am handling it like this. Can it be done better or faster?

       IEnumerator RecordFrame()
        {
            yield return new WaitForEndOfFrame();

            ScreenCapture.CaptureScreenshotIntoRenderTexture(_flippedTexture);
            Graphics.Blit(_flippedTexture, m_sendTexture, new Vector2(1.0f, -1.0f), new Vector2(0.0f, 1.0f));
        }

@karasusan
Copy link
Collaborator

@burakkaraceylan
Nice. We have a plan fixing this issue that adding a flag to flip texture to VideoStreamTrack.

@yinhew
Copy link

yinhew commented Jan 7, 2022

For now I am handling it like this. Can it be done better or faster?

       IEnumerator RecordFrame()
        {
            yield return new WaitForEndOfFrame();

            ScreenCapture.CaptureScreenshotIntoRenderTexture(_flippedTexture);
            Graphics.Blit(_flippedTexture, m_sendTexture, new Vector2(1.0f, -1.0f), new Vector2(0.0f, 1.0f));
        }

@burakkaraceylan How did you apply this work around?
This code is part of the package.
How did you edit the code after you installed the package?

I installed the WebRTC package following https://github.com/Unity-Technologies/com.unity.webrtc/blob/develop/Documentation~/install.md#case-of-unity-20203
Did you do the same?

@burakkaraceylan
Copy link
Author

@yinhew I cloned the git repo and installed from disk to get the latest version. But, you should still be able to edit the scripts anyway. It's an open source package and screen stream sender is just a C# script. However, what I did was I cloned the screen stream sender script and made my own version where I fiddle with it and use it in the stream list.

@yinhew
Copy link

yinhew commented Jan 7, 2022

Got it, thanks a lot! @burakkaraceylan

@karasusan
Copy link
Collaborator

This issue is fixed #630.
The new version will be released in this month.

@karasusan karasusan added the waiting for release This issue is already fixed and will be contained in next version label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working issued This means the ticket is already created on internal issue tracker waiting for release This issue is already fixed and will be contained in next version
Projects
None yet
3 participants