Jasonette / Jasonette/JASONETTE-Android
[BUG] $snapshot malfunction
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 266
- PR merge metrics
- No merged PRs in 30d
Description
Good afternoon,
Jasonette version : N/A
Jason version : 0.9.0 (installed from PlayStore)
Android version : 6.0.1
Device : Samsung Galaxy A5 2017
How to reproduce behaviour :
- open [https://jasonbase.com/things/dR7p](https://jasonbase.com/things/dR7p) in Jason on Android
- after 5 seconds, a snapshot of the screen is taken, then available for sharing via GMail, Bluetooth, etc.
- view the snapshot with any picture viewer : it is empty or nonsense
I suspect the problem stems from two different approaches to handing data_uri field building between $media.camera on one hand, and $snapshot on the other hand. More specifically:
- when dealing with the result of $media.camera activity, [JasonMediaAction.java](https://github.com/Jasonette/JASONETTE-Android/blob/fff152dfbd48ee743e539a4114a74ba1149eaac9/app/src/main/java/com/jasonette/seed/Action/JasonMediaAction.java) builds it as follows:
`InputStream stream = context.getContentResolver().openInputStream(uri);`
`byte[] byteArray = JasonHelper.readBytes(stream);`
- whereas when building up from $snapshot, [JasonViewActivity.java](https://github.com/Jasonette/JASONETTE-Android/blob/fff152dfbd48ee743e539a4114a74ba1149eaac9/app/src/main/java/com/jasonette/seed/Core/JasonViewActivity.java) performs:
`ByteArrayOutputStream stream = new ByteArrayOutputStream();`
`bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);`
`byte[] byteArray = stream.toByteArray();`
As the expected behaviour is obtained when using $media.camera, I guess there may be a problem with the code blob above for $snapshot.
JH
EDIT: after some digging, in particular @ [https://stackoverflow.com/questions/30196965/how-to-take-a-screenshot-of-current-activity-and-then-share-it](https://stackoverflow.com/questions/30196965/how-to-take-a-screenshot-of-current-activity-and-then-share-it), I suspect that the problem lies in the way $snapshot is trying to make a screenshot; specifically, I wonder whether the getDrawingCache() method is used on a GLSurfaceView, in which case the failure is expected.
Contributor guide
Research direction
Start in JasonViewActivity.java, where $snapshot builds the screenshot, and compare its bitmap handling with JasonMediaAction.java's camera data path. Reproduce the JasonBase example on the stated Android device or an equivalent environment, then inspect the screenshot path and the possible GLSurfaceView/getDrawingCache interaction. Done means the shared snapshot opens as a valid image rather than empty or corrupted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100