minicap icon indicating copy to clipboard operation
minicap copied to clipboard

Minicap getting blocked while capturing images

Open parasharg8 opened this issue 8 years ago • 19 comments

Phone Details:

manufacturer: 'Google/Motorola' model: 'Nexus 6' version: '7.0' abi: 'armeabi-v7a' sdk: '24'

After starting the minicap on the above mentioned device, the minicap is getting blocked and is not returning any output

adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0 PID: 29358 INFO: Using projection 1440x2560@1440x2560/0 INFO: (external/MY_minicap/src/minicap_24.cpp:240) Creating SurfaceComposerClient INFO: (external/MY_minicap/src/minicap_24.cpp:243) Performing SurfaceComposerClient init check INFO: (external/MY_minicap/src/minicap_24.cpp:250) Creating virtual display INFO: (external/MY_minicap/src/minicap_24.cpp:256) Creating buffer queue INFO: (external/MY_minicap/src/minicap_24.cpp:261) Creating CPU consumer INFO: (external/MY_minicap/src/minicap_24.cpp:265) Creating frame waiter INFO: (external/MY_minicap/src/minicap_24.cpp:269) Publishing virtual display INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder

The minicap will be blocked at this and will not continue. What could be possible reason for this?

parasharg8 avatar Dec 27 '16 14:12 parasharg8

Are you reading the frames from the socket it opens? On Tue, Dec 27, 2016 at 23:16 parasharg8 [email protected] wrote:

Phone Details:

manufacturer: 'Google/Motorola'

model: 'Nexus 6'

version: '7.0'

abi: 'armeabi-v7a'

sdk: '24'

After starting the minicap on the above mentioned device, the minicap is getting blocked and is not returning any output

adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0PID: 29358INFO: Using projection 1440x2560@1440x2560/0INFO: (external/MY_minicap/src/minicap_24.cpp:240) Creating SurfaceComposerClientINFO: (external/MY_minicap/src/minicap_24.cpp:243) Performing SurfaceComposerClient init checkINFO: (external/MY_minicap/src/minicap_24.cpp:250) Creating virtual displayINFO: (external/MY_minicap/src/minicap_24.cpp:256) Creating buffer queueINFO: (external/MY_minicap/src/minicap_24.cpp:261) Creating CPU consumerINFO: (external/MY_minicap/src/minicap_24.cpp:265) Creating frame waiterINFO: (external/MY_minicap/src/minicap_24.cpp:269) Publishing virtual displayINFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder

The minicap will be blocked at this and will not continue.

What could be possible reason for this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openstf/minicap/issues/51, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB-_bV3nJzIlkLAQLki9iFoxtIWlq4Eks5rMR3QgaJpZM4LWTGV .

sorccu avatar Dec 27 '16 14:12 sorccu

Yes I am reading the frames from the socket it opens. But the minicap is blocking even before I start reading the frames.

Steps of execution in our code:

  1. Starting minicap using command === adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0

  2. Creating a local forward to connect to the socket using command === adb forward tcp:$(port) localabstract:minicap .

  3. Reading the frames from the socket created on the port used in the command in step 2.

I am facing problem in step 1 itself where while starting minicap, the minicap is getting blocked due to which we are not able to move to step 2.

Please Note : I am facing this issue only on Android 7. Devices on earlier android versions are working fine with the same code and same steps of execution.

parasharg8 avatar Dec 28 '16 06:12 parasharg8

Here is the new finding on this issue.

If I run the manually command to start the minicap once, then the minicap gets hanged and we are not able to proceed. But on the other hand if I run the command twice and that too seperately on two different command prompts, then the minicap runs fine on second command prompt.

Find below the output of commands run :

  1. The minicap startup command run for first time

             **D:\>adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-   devel/minicap -P 1440x2560@1440x2560/0
           PID: 4345
           INFO: Using projection 1440x2560@1440x2560/0
           INFO: (external/MY_minicap/src/minicap_24.cpp:240) Creating SurfaceComposerClient
            INFO: (external/MY_minicap/src/minicap_24.cpp:243) Performing SurfaceComposerClient init check
           INFO: (external/MY_minicap/src/minicap_24.cpp:250) Creating virtual display
           INFO: (external/MY_minicap/src/minicap_24.cpp:256) Creating buffer queue
            INFO: (external/MY_minicap/src/minicap_24.cpp:261) Creating CPU consumer
           INFO: (external/MY_minicap/src/minicap_24.cpp:265) Creating frame waiter
           INFO: (external/MY_minicap/src/minicap_24.cpp:269) Publishing virtual display
           INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder**
    
  2. The minicap startup command run for second time

          **D:\>adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0
         PID: 3459
         INFO: Using projection 1440x2560@1440x2560/0
         INFO: (external/MY_minicap/src/minicap_24.cpp:240) Creating SurfaceComposerClient
         INFO: (external/MY_minicap/src/minicap_24.cpp:243) Performing SurfaceComposerClient init check
         INFO: (external/MY_minicap/src/minicap_24.cpp:250) Creating virtual display
         INFO: (external/MY_minicap/src/minicap_24.cpp:256) Creating buffer queue
         INFO: (external/MY_minicap/src/minicap_24.cpp:261) Creating CPU consumer
         INFO: (external/MY_minicap/src/minicap_24.cpp:265) Creating frame waiter
         INFO: (external/MY_minicap/src/minicap_24.cpp:269) Publishing virtual display
         INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder
         INFO: (external/MY_minicap/src/minicap_24.cpp:284) Destroying virtual display
    
         D:\>**
    

As we can see from the above mentioned outputs of the minicap startup command that the minicap started successfully in the second attempt while the first attempt continues to block. What can be the possible root cause for this behaviour?

Please Note: The minicap startup command which we are using is adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0

parasharg8 avatar Dec 28 '16 13:12 parasharg8

You should check logcat. First, before running anything, clear it:

adb logcat -c

Then run

adb logcat > out.log

(or whatever the windows equivalent might be)

Now run that command again, wait for it to hang, stop logcat and go through the file to see if there's anything interesting in there.

sorccu avatar Dec 28 '16 13:12 sorccu

@sorccu : Thanks for the advice. We ran the steps as mentioned by you and we are not seeing anything faulty except that I have seen the below line 2-3 times.

        **SurfaceFlinger: couldn't log to binary event log: overflow.**

Will this cause any unexpected behavior in minicap?

parasharg8 avatar Dec 28 '16 14:12 parasharg8

Are you definitely running stock Android and not a custom build? Also, have you triple checked that you're using the latest minicap binaries and .so libs?

On Wed, Dec 28, 2016 at 23:15 parasharg8 [email protected] wrote:

@sorccu https://github.com/sorccu : Thanks for the advice. We ran the steps as mentioned by you and we are not seeing anything faulty except that I have seen the below line 2-3 times.

    **SurfaceFlinger: couldn't log to binary event log: overflow.**

Will this cause any unexpected behavior in minicap?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/openstf/minicap/issues/51#issuecomment-269482441, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB-_QG5gAnFlxoQtg-wgiFC1X35pweCks5rMm7qgaJpZM4LWTGV .

sorccu avatar Dec 28 '16 14:12 sorccu

Yes I am running stock Android. I updated the Nexus 6 from Android-6 to Android-7 by going to Settings->About Phone-> System Updates.

Also, I have made a fresh clone of the repository and created new minicap binaries. And before pushing the new binaries, I made sure that old binaries are deleted from the device and then only new binaries are pushed into the device

parasharg8 avatar Dec 28 '16 14:12 parasharg8

Hi

Do you have any suggestion i am still getting this problem?. When i am executing this below command using Java Process API, The Input stream got hanged and execution blocks at BufferedReader.readline().

adb shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0

Hope this will help.

parasharg8 avatar Jan 06 '17 06:01 parasharg8

You can't use readLine, there are no lines in the minicap stream.

sorccu avatar Jan 06 '17 06:01 sorccu

Below is the log related to minicap which i am getting from Logcat.

01-06 12:41:37.555 13864 13864 W minicap : type=1400 audit(0.0:810): avc: denied { accept } for scontext=u:r:shell:s0 tcontext=u:r:adbd:s0 tclass=unix_stream_socket permissive=0

I am executing this command through Java Process Api.

adb -s ZX1G424G66 shell LD_LIBRARY_PATH=/data/local/tmp/minicap-devel /data/local/tmp/minicap-devel/minicap -P 1440x2560@1440x2560/0

Thanks, Do let me know if you found any thing suspicious in this.

parasharg8 avatar Jan 06 '17 07:01 parasharg8

As of now it appear Minicap is not opening any stream, That is why program execution got hanged even if i read character from stream.

Your thoughts?.

parasharg8 avatar Jan 06 '17 08:01 parasharg8

Wait so does your Java program run directly on the device, or on your computer? On Fri, Jan 6, 2017 at 17:33 parasharg8 [email protected] wrote:

As of now it appear Minicap is not opening any stream, That is why program execution got hanged even if i read character from stream.

Your thoughts?.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/openstf/minicap/issues/51#issuecomment-270856150, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB-_f-snXJFo4vfbqsFU5_wgWw_dIR_ks5rPfxrgaJpZM4LWTGV .

sorccu avatar Jan 06 '17 08:01 sorccu

Java program run on Computer.

parasharg8 avatar Jan 06 '17 08:01 parasharg8

Do you have any other device to test with? On Fri, Jan 6, 2017 at 17:38 parasharg8 [email protected] wrote:

Java program run on Computer.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/openstf/minicap/issues/51#issuecomment-270856888, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB-_YdePZaG5iXwEdVe5RjKh7GsltTtks5rPf2GgaJpZM4LWTGV .

sorccu avatar Jan 06 '17 08:01 sorccu

minicap : type=1400 audit(0.0:20): avc: denied { accept } for scontext=u:r:shell:s0 tcontext=u:r:adbd:s0 tclass=unix_stream_socket permissive=0

01-06 14:46:08.236 6064 6067 E BufferQueueProducer: [minicap] dequeueBuffer: BufferQueue has been abandoned 01-06 14:46:08.245 299 299 E SurfaceFlinger: [minicap] advanceFrame: no buffer, bailing out 01-06 14:46:08.245 299 299 E DisplayDevice: [minicap] failed pushing new frame to HWC: -12

I found these on the device logcat. Please have a look.

parasharg8 avatar Jan 06 '17 09:01 parasharg8

Your device is weird, I'm afraid I don't have much time to look into this as my free time is very limited. All Nexus devices should work fine, even on 7 and 7.1.

Have you tried running using stf? Does it work there?

Another thing I can think of is that maybe your kernel/SELinux is in restrictive mode. Might be worth trying if you can change it in settings. You shouldn't need to do that but try anyway.

On Fri, Jan 6, 2017 at 18:40 parasharg8 [email protected] wrote:

minicap : type=1400 audit(0.0:20): avc: denied { accept } for scontext=u:r🐚s0 tcontext=u:r:adbd:s0 tclass=unix_stream_socket permissive=0

01-06 14:46:08.236 6064 6067 E BufferQueueProducer: [minicap] dequeueBuffer: BufferQueue has been abandoned

01-06 14:46:08.245 299 299 E SurfaceFlinger: [minicap] advanceFrame: no buffer, bailing out

01-06 14:46:08.245 299 299 E DisplayDevice: [minicap] failed pushing new frame to HWC: -12

I found these on the device logcat. Please have a look.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/openstf/minicap/issues/51#issuecomment-270866477, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB-_VeNEiTRdc1OVSk8JIB40Sq2EeAhks5rPgv5gaJpZM4LWTGV .

sorccu avatar Jan 06 '17 09:01 sorccu

7.X is ok. maybe you do that with JAVA or else, you can check minicap with -t firstly , if ok , don't need to care the output with start minicap server command @parasharg8

ghost avatar May 04 '17 04:05 ghost

maybe it's not blocked, try to scroll your screen?

uname avatar Dec 13 '18 03:12 uname

On some devices, mostly older ones, it can get stuck if you don’t read frames quickly enough. It’ll run out of buffer space and stop. On most devices it simply discards unread frames on pressure.

sorccu avatar Dec 13 '18 03:12 sorccu