Closed 0k1019 closed 3 years ago
Thanks for your findings! I was able to reproduce the issue and I'm working on fixing it.
Actually I was wrong.
I was able to reproduce the issue using MTLPixelFormat.bgra10_xr_srgb, but it should be an impossible format for any SCNView related views.
@0k1019 Can you please tell me what is the pixelFormat of CAMetalLayer you have in iOS 13 on iPad and iPhone?
You can grab it, for example near takePhoto
function call.
e.g. print(sceneView.recordableLayer!.pixelFormat.rawValue)
@v-grigoriev
I run print(sceneView.recordableLayer!.pixelFormat.rawValue)
.
The result is 81 (MTLPixelFormat.bgra8Unorm_srgb) in iOS 13 on iPhone and iPad.
Below text and photo are about log and Fatal error screen shot.
2020-11-23 10:46:09.518798+0900 Example[277:5553] Metal GPU Frame Capture Enabled 2020-11-23 10:46:09.518993+0900 Example[277:5553] Metal API Validation Enabled before takePhoto function call sceneView.recordableLayer!.pixelFormat.rawValue: 81 after takePhoto function call sceneView.recordableLayer!.pixelFormat.rawValue: 81 Fatal error: Unexpectedly found nil while unwrapping an Optional value: file SCNRecorder/ImageOutput.swift, line 60 2020-11-23 10:46:18.099552+0900 Example[277:5703] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file SCNRecorder/ImageOutput.swift, line 60
@0k1019 Can you please test with 2.3.0?
@v-grigoriev Thank you. It works really well in example project! Can you tell me what kinds of problem briefly?(I try to understand your commit, but there are a lot refactoring and fixing bug codes.)
Sure, starting with 2.1 to support iOS 14 on iPhone 12 and iPad Pro 2020 I changed the way to capture pixel buffers from MTLTexture. Instead of getBytes
, I started using iosurface
to create CVPixelBuffer. And it works on iOS 14 without any problem.
But it seems iOS 13 Video Toolbox doesn't support such pixel buffers, so I reverted the change for iOS 13.
And now I have an idea of how to make all of this even better. I'm working on a solution that uses Metal Performance Shaders to properly and fast capture pixel buffers. And I'm going to add unit tests for testing with all supported pixel formats on various devices and iOS versions to prevent such crashes in the future.
Thank you wonderful explanation. I look forward to your roadmap(MPS, unit test...).
The update is ready. I hope it will prevent any future issues.
Hello, Thank you for wonderful project.
I bump up the library version to 2.0.0 to 2.2.0. After I update version, I can't take photo with crash log. And no video after video recording.
I have some devices and I test "SCNRecorder".
I test by checkout following project tag 2.0.0, 2.1.3 and 2.2.0. And run Example Project. In
ARSCNView Example
On version 2.0.0
Nice working
Not working
On version 2.1.3
Nice working
Not working
On version 2.2.0
Nice working
Not working
Clue
I try to find clue I find
TakePhoto
VTCreateCGImageFromCVPixelBuffer
function is not working correctly iOS 13.I can't find any clue
StartVideoRecording
I think OS version dependent on this project. Please check.
Hope you find reason soon!