[OnePlus 2 Original Android Development] koniiiik:
I'm back with more information about the camera issue. The TL;DR of it is that cameraserver is leaking memory and file descriptors.

I let the phone run with droidcam on while capturing logs, and here's what the transition from working camera to broken looks like (with `logcat -v long`):

[ 11-24 18:21:55.141 742:13016 I/mm-camera-sensor ]
sensor_calculate_exposure:62 sensor_calculate_exposure:real_gain=4.387069,reg_gain=0x46,sensor_real_gian=4.375000,digital_gain=1.002759

[ 11-24 18:21:55.149 9095:13035 I/47 ]
Connection from 192.168.0.35

[ 11-24 18:21:55.209 742:13016 I/mm-camera-sensor ]
sensor_calculate_exposure:62 sensor_calculate_exposure:real_gain=4.387069,reg_gain=0x46,sensor_real_gian=4.375000,digital_gain=1.002759

[ 11-24 18:21:55.210 4216:13028 E/QCameraHWI_Mem ]
registerBuffer: failed: could not open ion device

[ 11-24 18:21:55.210 4216:13028 E/QCamera3Channel ]
registerBuffer: Buffer 0xf00025e0 couldn't be registered -12

[ 11-24 18:21:55.210 4216:13028 E/QCamera3Channel ]
request: On-the-fly buffer registration failed -12

[ 11-24 18:21:55.210 4216:13028 E/QCamera3HWI ]
processCaptureRequest: request failed

[ 11-24 18:21:55.213 4216:14699 E/QCamera3HWI ]
translateFromHalMetadata: Invalid CAC camera parameter: 1065323518

[ 11-24 18:21:55.280 4216:14699 E/QCamera3HWI ]
translateFromHalMetadata: Invalid CAC camera parameter: 1065323518

[ 11-24 18:21:55.281 742:13016 I/mm-camera-sensor ]
sensor_calculate_exposure:62 sensor_calculate_exposure:real_gain=4.387069,reg_gain=0x46,sensor_real_gian=4.375000,digital_gain=1.002759

[ 11-24 18:21:55.351 4216:14699 E/QCamera3HWI ]
translateFromHalMetadata: Invalid CAC camera parameter: 1065323518

[ 11-24 18:21:55.351 742:13016 I/mm-camera-sensor ]
sensor_calculate_exposure:62 sensor_calculate_exposure:real_gain=4.387069,reg_gain=0x46,sensor_real_gian=4.375000,digital_gain=1.002759

[ 11-24 18:21:55.422 4216:14699 E/QCamera3HWI ]
translateFromHalMetadata: Invalid CAC camera parameter: 1065323518

[ 11-24 18:21:55.424 742:13016 I/mm-camera-sensor ]
sensor_calculate_exposure:62 sensor_calculate_exposure:real_gain=4.387069,reg_gain=0x46,sensor_real_gian=4.375000,digital_gain=1.002759

[ 11-24 18:21:55.490 742:13016 I/mm-camera-sensor ]
sensor_calculate_exposure:62 sensor_calculate_exposure:real_gain=4.387069,reg_gain=0x46,sensor_real_gian=4.375000,digital_gain=1.002759

[ 11-24 18:21:55.492 4216:14699 E/QCamera3HWI ]
translateFromHalMetadata: Invalid CAC camera parameter: 1065323518

[ 11-24 18:21:55.564 4216:13028 E/Parcel ]
fcntl(F_DUPFD_CLOEXEC) failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 2, error: Too many open files

[ 11-24 18:21:55.564 4216:13028 E/Surface ]
dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -22

[ 11-24 18:21:55.565 4216:13028 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 7: Can't dequeue next output buffer: Invalid argument (-22)

[ 11-24 18:21:55.565 4216:13028 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000014

[ 11-24 18:21:55.566 4216:13028 E/Parcel ]
fcntl(F_DUPFD_CLOEXEC) failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 2, error: Too many open files

[ 11-24 18:21:55.566 4216:13028 E/Surface ]
dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -22

[ 11-24 18:21:55.566 4216:13028 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 7: Can't dequeue next output buffer: Invalid argument (-22)

[ 11-24 18:21:55.566 4216:13028 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000014

[ 11-24 18:21:55.568 4216:13028 E/Parcel ]
fcntl(F_DUPFD_CLOEXEC) failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 2, error: Too many open files

[ 11-24 18:21:55.568 4216:13028 E/Surface ]
dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -22

[ 11-24 18:21:55.568 4216:13028 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 7: Can't dequeue next output buffer: Invalid argument (-22)

[ 11-24 18:21:55.568 4216:13028 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000014

[ 11-24 18:21:55.569 4216:13028 E/Parcel ]
fcntl(F_DUPFD_CLOEXEC) failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 2, error: Too many open files

[ 11-24 18:21:55.569 4216:13028 E/Surface ]
dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -22

[ 11-24 18:21:55.570 4216:13028 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 7: Can't dequeue next output buffer: Invalid argument (-22)

[ 11-24 18:21:55.570 4216:13028 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000014

[ 11-24 18:21:55.571 4216:14699 E/QCamera3HWI ]
translateFromHalMetadata: Invalid CAC camera parameter: 1065323518

[ 11-24 18:21:55.571 4216:13028 E/Parcel ]
fcntl(F_DUPFD_CLOEXEC) failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 2, error: Too many open files

[ 11-24 18:21:55.571 4216:13028 E/Surface ]
dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -22

You can see that before the 18:21:55.564 mark, everything looks normal (the “Invalid CAC camera parameter” errors get spammed all the time when the camera works), but then at 18:21:55.564, we can see that the file descriptors get exhausted. This state persists for about a second, and then about a second later, the following appears in the log:

[ 11-24 18:21:56.408 4216:13028 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 7: Can't dequeue next output buffer: Unknown error 2147483646 (-2147483646)

[ 11-24 18:21:56.408 4216:13028 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000014

[ 11-24 18:21:56.408 4216:13028 E/QCameraHWI_Mem ]
registerBuffer: failed: could not open ion device

[ 11-24 18:21:56.408 4216:13028 E/QCamera3Channel ]
registerBuffer: Buffer 0xf00021a8 couldn't be registered -12

[ 11-24 18:21:56.408 4216:13028 E/QCamera3Channel ]
request: On-the-fly buffer registration failed -12

[ 11-24 18:21:56.408 4216:13028 E/QCamera3HWI ]
processCaptureRequest: request failed

[ 11-24 18:21:56.408 4216:13028 E/QCameraHWI_Mem ]
registerBuffer: failed: could not open ion device

[ 11-24 18:21:56.408 4216:13028 E/QCamera3Channel ]
registerBuffer: Buffer 0xf00022c8 couldn't be registered -12

[ 11-24 18:21:56.408 4216:13028 E/QCamera3Channel ]
request: On-the-fly buffer registration failed -12

[ 11-24 18:21:56.408 4216:13028 E/QCamera3HWI ]
processCaptureRequest: request failed

[ 11-24 18:21:56.458 742:13011 E/mm-camera ]
v4l2 ioctl() failed. rc:-1, trans_code:-11, stream_id=2

[ 11-24 18:21:56.458 742:13011 E/mm-camera ]
retry=0

[ 11-24 18:21:56.459 742:13011 E/mm-camera ]
v4l2 ioctl() failed. retry=0

[ 11-24 18:21:56.459 742:13011 E/mm-camera ]
retry=1

[ 11-24 18:21:56.460 742:13011 E/mm-camera ]
v4l2 ioctl() failed. retry=1

[ 11-24 18:21:56.461 742:13011 E/mm-camera ]
retry=2

[ 11-24 18:21:56.462 742:13011 E/mm-camera ]
v4l2 ioctl() failed. retry=2

[ 11-24 18:21:56.462 742:13011 E/mm-camera ]
retry=3

[ 11-24 18:21:56.463 742:13011 E/mm-camera ]
v4l2 ioctl() failed. retry=3

[ 11-24 18:21:56.463 742:13011 E/mm-camera ]
retry=4

[ 11-24 18:21:56.464 742:13011 E/mm-camera ]
v4l2 ioctl() failed. retry=4

[ 11-24 18:21:56.464 742:13011 E/mm-camera ]
drop this frame

[ 11-24 18:21:56.464 742:13011 E/mm-camera ]
drop this frame

[ 11-24 18:21:56.464 742:13011 E/mm-camera ]
cpp_thread_handle_process_buf_event:325, dropped frame id=121056 identity=0x30002

[ 11-24 18:21:56.474 742:13016 I/mm-camera-sensor ]
sensor_calculate_exposure:62 sensor_calculate_exposure:real_gain=4.387069,reg_gain=0x46,sensor_real_gian=4.375000,digital_gain=1.002759

[ 11-24 18:21:56.480 4216:13028 E/GraphicBufferAllocator ]
Failed to allocate (1280 x 720) layerCount 1 format 35 usage 20003: 5

[ 11-24 18:21:56.480 4216:13028 E/BufferQueueProducer ]
[Camera2-CallbackConsumer] dequeueBuffer: createGraphicBuffer failed

[ 11-24 18:21:56.480 4216:13028 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 2: Can't dequeue next output buffer: Out of memory (-12)

[ 11-24 18:21:56.480 4216:13028 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000014

[ 11-24 18:21:56.481 4216:13028 E/GraphicBufferAllocator ]
Failed to allocate (1280 x 720) layerCount 1 format 35 usage 20003: 5

[ 11-24 18:21:56.481 4216:13028 E/BufferQueueProducer ]
[Camera2-CallbackConsumer] dequeueBuffer: createGraphicBuffer failed

[ 11-24 18:21:56.481 4216:14699 E/QCamera3HWI ]
translateFromHalMetadata: Invalid CAC camera parameter: 1065323518

[ 11-24 18:21:56.481 4216:13028 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 2: Can't dequeue next output buffer: Out of memory (-12)

…and these messages loop for the rest of eternity.

Stopping the application trying to access the camera, and trying again, gets rid of the OOM messages, and switches to the following pattern (which I believe to be the same as what I posted earlier):

[ 11-24 19:00:46.309 4216:21795 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 0: Can't dequeue next output buffer: Unknown error 2147483646 (-2147483646)

[ 11-24 19:00:46.309 4216:21795 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000005

[ 11-24 19:00:46.309 4216:21795 E/Surface ]
dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -2147483646

[ 11-24 19:00:46.309 4216:21795 E/Camera3-OutputStream ]
getBufferLockedCommon: Stream 0: Can't dequeue next output buffer: Unknown error 2147483646 (-2147483646)

[ 11-24 19:00:46.309 4216:21795 W/Camera2Client ]
notifyError: Received recoverable error 3 from HAL - ignoring, requestId 10000005

[ 11-24 19:00:46.309 4216:21795 E/Surface ]
dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -2147483646

Now, the process that experiences the FD and memory exhaustion here is the one with PID 4216, which is the following bugger:

cameraserver 4216 1 93712 16144 binder_th+ f18eddbc S cameraserver

And indeed, killing the cameraserver, and letting it get restarted by the system makes the camera work again.

The ticket can be found at https://gitlab.com/LineageOS/issues/android/-/issues/2671.