LongShootLegacy icon indicating copy to clipboard operation
LongShootLegacy copied to clipboard

getTime crash with RAW enabled

Open licaon-kter opened this issue 7 years ago • 26 comments

Mate 9 / OmniROM 9 0.5.3-alpha

Crash on press CAPTURE

22160 22179 E AndroidRuntime: Process: com.tyroneil.[01;31m[Klong[m[Kshootalpha, PID: 22160
22160 22179 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method '[01;31m[Klong[m[K java.util.Date.getTime()' on a null object reference
22160 22179 E AndroidRuntime: 	at com.tyroneil.[01;31m[Klong[m[Kshootalpha.MainActivity$7.onImageAvailable(MainActivity.java:964)
936  6266 W ActivityManager:   Force finishing activity com.tyroneil.[01;31m[Klong[m[Kshootalpha/.MainActivity
936  1029 W InputDispatcher: channel '7c14681 com.tyroneil.[01;31m[Klong[m[Kshootalpha/com.tyroneil.longshootalpha.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
936  1029 E InputDispatcher: channel '7c14681 com.tyroneil.[01;31m[Klong[m[Kshootalpha/com.tyroneil.longshootalpha.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

Also the About button doesn't seem to do anything.

licaon-kter avatar Jan 01 '19 10:01 licaon-kter

null when java.util.Date.getTime()??? This doesn't make sense. I will make some test build for you, please tell me which one still has this problem.

As to the About button, it's normal to do nothing, because I didn't write that part yet.

toymil avatar Jan 01 '19 16:01 toymil

[test][date_crash] 0.5.4-alpha please try these three builds, tell me which one will crash.

toymil avatar Jan 01 '19 16:01 toymil

They all crash, when pressing CAPTURE, same error message.

Disable RAW capture and then it doesn't crash anymore.

licaon-kter avatar Jan 01 '19 17:01 licaon-kter

They all crash, when pressing CAPTURE, same error message.

Disable RAW capture and then it doesn't crash anymore.

Disable RAW then all of it won't crash?

toymil avatar Jan 01 '19 18:01 toymil

Oh, there is corrupted characters in the logcat you pasted, I don't know if it's just on my end.

toymil avatar Jan 01 '19 18:01 toymil

That's my ROM, it outputs some fancy styling, not an issue,

licaon-kter avatar Jan 01 '19 19:01 licaon-kter

Can you get the stack trace? It should be in the logcat.

toymil avatar Jan 02 '19 01:01 toymil

There's nothing more in the log.

licaon-kter avatar Jan 02 '19 09:01 licaon-kter

There's nothing more in the log.

Oh, my bad. Didn't see the stack trace before because the corrupted characters.

The bad news is, the only thing related to date around line 964 is simpleDateFormat.format(imageTimeStamp), then the null exception must comes from imageTimeStamp; but if imageTimeStamp is a null reference, this bug must happen to both JPEG and RAW, and it should not occur in one of the test build I made for you before.

toymil avatar Jan 02 '19 15:01 toymil

Yet, they all behave the same, crash there or no crash without RAW.

licaon-kter avatar Jan 02 '19 15:01 licaon-kter

Later I will make a test build with simpleDateFormat.format(imageTimeStamp) replaced by a fixed string, see if it can prevent crash

toymil avatar Jan 02 '19 15:01 toymil

0.5.5-alpha.test.getTime.null.apk.zip GitHub only support some format as attachments...

I just discovered something, and I think the build above may still gonna crash, but try it.

I change the DNG file name to a fixed string, didn't change it for JPEG.

toymil avatar Jan 02 '19 15:01 toymil

So as expected? AndroidRuntime: at com.tyroneil.[01;31m[Klong[m[Kshootalpha.MainActivity$7.onImageAvailable(MainActivity.java:980)

licaon-kter avatar Jan 02 '19 16:01 licaon-kter

Right, I know what's the problem now. But, it should crash first at line 1051 if I'm correct...

toymil avatar Jan 02 '19 16:01 toymil

0.5.5-alpha.test.totalCaptureResult.null.apk.zip

Try this, if it did not crash, look for log with tag LSA_WARNING, level warning.

toymil avatar Jan 02 '19 16:01 toymil

Not sure what warning were you expecting, I don't have those.

Only the crash: AndroidRuntime: at com.tyroneil.[01;31m[Klongshoot[m[Kalpha.MainActivity$7.onImageAvailable(MainActivity.java:977)

licaon-kter avatar Jan 02 '19 16:01 licaon-kter

It's really imageTimeStamp, then deeper totalCaptureResult.get(CaptureResult.SENSOR_TIMESTAMP).

Try this 0.5.5-alpha.test.totalCaptureResult.null.1.apk.zip

The problem though, is that, as to the documents, totalCaptureResult.get(CaptureResult.SENSOR_TIMESTAMP) shouldn't be null.

As to the warning, I mean something like this: adb logcat LSA_WARNING:W.

toymil avatar Jan 02 '19 17:01 toymil

~~Can't download: "This page is taking way too long to load."~~

I use logcat -i longshoot, your line has too much noise.

/LE: it worked to download later

licaon-kter avatar Jan 02 '19 17:01 licaon-kter

You mean it didn't crash? Did you see any logcat with LSA_WARNING tag?

~I tried my line, you are right; but it should filter only log with that tag, I don't know what's wrong.~ Figured out, should use adb logcat LSA_WARNING:W *:S

toymil avatar Jan 02 '19 18:01 toymil

Still crashes: E AndroidRuntime: at com.tyroneil.[01;31m[Klongsh[m[Kootalpha.MainActivity$7.onImageAvailable(MainActivity.java:977)

licaon-kter avatar Jan 03 '19 10:01 licaon-kter

What??? Try this build 0.5.5-alpha.test.fixedName.noTimeStampVerification.apk.zip. This should produce RAW with a fixed file name and without time stamp verification (nothing related to time now).

Expected behaviour:

  • JPEG behave same as before
  • RAW will not crash, but save every photo with the same name

Because I can't reproduce it on my phone, all I can do is guess based on your log. Now I'm getting confused what really cause the crash.

toymil avatar Jan 03 '19 16:01 toymil

The same: AndroidRuntime: at com.tyroneil.[01;31m[Klongsh[m[Kootalpha.MainActivity$7.onImageAvailable(MainActivity.java:987)

licaon-kter avatar Jan 03 '19 18:01 licaon-kter

The error is still getTime() null? Line 987 is:

DngCreator dngCreator = new DngCreator(cameraCharacteristics, totalCaptureResult);

totalCaptureResult is the metadata comes straight out form capture, it is essential to save the DNG file, and I did not modify it.
It looks like your ROM has RAW support (actually I should check it from cameraCharacteristics), but the support has some problem.
One thing more I can do is to check the cameraCharacteristics. if it says the device has RAW support, and it crash like you described, then it is a problem with the ROM.

toymil avatar Jan 03 '19 18:01 toymil

@licaon-kter I just realized there is a simple way to see if it is a bug with my app.

Try this googlesamples_android-Camera2Raw.zip. It's a camera2 RAW capture sample made by Google.

If it works, takes photos and save them under DCIM directory, it means RAW support has no problem.

toymil avatar Jan 04 '19 00:01 toymil

Try this googlesamples_android-Camera2Raw.zip.

Works fine, it captures DNGs.

licaon-kter avatar Jan 04 '19 18:01 licaon-kter

Well, then I will try to find the difference between my app and the sample

toymil avatar Jan 04 '19 18:01 toymil