SharpAdb / AdvancedSharpAdbClient

AdvancedSharpAdbClient is a .NET library that allows .NET, Mono and Unity applications to communicate with Android devices. It's improved version of SharpAdbClient.
https://sharpadb.github.io
Apache License 2.0
203 stars 54 forks source link

Getting Image screen shot and data array wrong size #26

Closed devnightmare closed 2 years ago

devnightmare commented 2 years ago

Describe the bug

1.Any Time I try to create either a refreshable buffer from client or try to create a one time screen shoot I get a "cannot read past end of stream error." I tracked this down to being for the reader. When the project gets the header it doesn't set properly in FrameBuffer loading. 2.There was also an issue where the initlized data array from arraypool was renting a little under twice the size needed. This would cause a issue on Header.ToImage(Data) to say image buffer larger then expected.

Steps to reproduce the bug

using code as documented in start up.

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

.NET Platform

.NET 6

Platform type

Windows

System version

2.5.2

IDE

Visual Studio 2022

Additional context

I was able to make a copy of data and fix the issues. I will be submit detailed spots where it could be fixed later. Until then I am using a copy from the class in its own function in my code to get screen shot.

vbarashkov commented 2 years ago

Code:

Image img = _client.GetFrameBufferAsync(_device, CancellationToken.None).GetAwaiter().GetResult();

Exception:

An unhandled exception has occurred while executing the request.
      System.ArgumentException: The buffer is not associated with this pool and may not be returned to it. (Parameter 'array')
         at System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1.Return(T[] array, Boolean clearArray)

Connect to Bluestack 1920x1080 320dpi