jraska / Falcon

Take Android screenshots with Falcons bright eye!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting exception

nagesh-kashyap-r opened this issue · comments

Please help.

i'm getting this exception

"Attempt to read from field 'android.graphics.Rect android.view.View$AttachInfo.mTmpInvalRect' on a null object reference"

This exception occurs occasionally.
Could not find exact issue.

Calling .takeScreenshotBitmap() inside a ScheduledThreadPoolExecutor to take ScreenShots continuously (5 ScreenShots per sec).

Should i call the function .takeScreenshotBitmap() on UI thread?

Thanks.

Hello, thank you for using the library and I'm sorry for the issue.

Falcon switches to UI thread automatically, so doing this off the UI thread on Executor isn't an issue.

It sounds like there is tiny time window where those fields can be null. Could you please post here the stack?

I will have a look but I guess there is no fix and Falcon will just fail with UnableToTakeScreenshotException. Workaround for you could be something like:

try {
  bitmap = Falcon.takeScreenshotBitmap(activity);
} catch(UnableToTakeScreenshotException ex){
  Log.e("Cannot take screenshot: " + ex.getMessage());
}

Sorry for late reply,

I couldn't reproduce the issue.

I'll post the stack-trace later.

Thanks

Ok, please reopen the issue if you will still have the problem.

My suggestion would be as I wrote to wrap the Falcon method with try catch and do error handling logic.

try {
  bitmap = Falcon.takeScreenshotBitmap(activity);
} catch(UnableToTakeScreenshotException ex){
  Log.e("Cannot take screenshot: " + ex.getMessage());
}

Other thing is Falcon does not even access android.view.View$AttachInfo.mTmpInvalRect so I'm not sure how this exception occurs during screenshot capturing.