dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.62k stars 347 forks source link

When using takeSnapshot on apps that actively block this action, don't crash #194

Closed meirtsvi closed 8 years ago

meirtsvi commented 8 years ago

In situations where app has screenshot protection, the viewclient takeSnapshot call crashes taking the whole process down. putting try/except around takeSnapshot does not help.

For strange reason, the solution is to simply replace "from PIL import Image" with "import Image"

dtmilano commented 8 years ago

I really think the issues are not related. Can you please provide more context? Which is the app that makes AndroidViewClient crash? What are the versions of all the software and platforms your are using? We could affect many combinations that are working now. As you can see, there's no other reports of combinations where this is a problem. Appreciate your help.

meirtsvi commented 8 years ago

In order to repro the crash use the following:

  1. Install SAP fiori client ver. 1.6.3 - http://www.apkmonk.com/app/com.sap.fiori.client/ on Samsung S5 Android ver. 5 (for some reason the crash happens only on this device)
  2. Open the app
  3. Run the attached script run.txt

Expected result: script shouldn't crash and should create a png. Actual result: error that crashes python process with the following message: No handlers could be found for logger "PIL.ImageFile" cannot identify image file <cStringIO.StringI object at 0x107f99ad0> <cStringIO.StringI object at 0x107f99ad0>

I'm using the latest release 11.5.9 on OSX Yosemite

I would really appreciate a fix that won't crash the entire process but rather enable me to catch some python exception even if the snapshot doesn't succeed.

dtmilano commented 8 years ago

Thanks for the detailed info. Interesting case. This patch ( https://github.com/dtmilano/AndroidViewClient/commit/b0f94b235cb548550ddaff091a62a96870dd0450) is fixing the problem or at least is throwing an exception that can be trapped.

try:
    device.takeSnapshot(reconnect=True).save(filename, 'png')
except:
    print "ERROR"

It will be tested and a new version will be uploaded soon.

On Mon, Jul 18, 2016 at 3:31 AM, Meir Tsvi notifications@github.com wrote:

In order to repro the crash use the following:

  1. Install SAP fiori client ver. 1.6.3 - http://www.apkmonk.com/app/com.sap.fiori.client/ on Samsung S5 Android ver. 5 (for some reason the crash happens only on this device)
  2. Open the app
  3. Run the attached script run.txt https://github.com/dtmilano/AndroidViewClient/files/368494/run.txt

Expected result: script shouldn't crash and should create a png. Actual result: error that crashes python process with the following message: No handlers could be found for logger "PIL.ImageFile" cannot identify image file <cStringIO.StringI object at 0x107f99ad0> <cStringIO.StringI object at 0x107f99ad0>

I'm using the latest release 11.5.9 on OSX Yosemite

I would really appreciate a fix that won't crash the entire process but rather enable me to catch some python exception even if the snapshot doesn't succeed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dtmilano/AndroidViewClient/pull/194#issuecomment-233254386, or mute the thread https://github.com/notifications/unsubscribe-auth/AA790icEa-lCCs8O-QSP-nBelGTonEuRks5qWyvigaJpZM4I_yeg .

Have you read my blog ? http://dtmilano.blogspot.com android junit tests ui linux cult thin clients

meirtsvi commented 8 years ago

Looks awesome. Can't wait for 11.5.10 to be out.

Thanks! Meir

meirtsvi commented 8 years ago

release 11.5.11 contains the proper fix - no need for this code change anymore