Discovered a timing issue when using the esp32-camera. The error indication is simple: with certain camera configuration, esp_camera_fb_get returns null_ptr. This is definitely a timing mismatch in the hardware and controller code. As far as I can see, the hardware is supposed to check the camera status and fill in the frame buffers in the PSRAM in an ISR in some constant frequency (related to config.xclk_freq_hz) and I fetch (and return) the frame buffer in the working loop. If one side is too slow or too fast, there will be no enough / too much events and the working queue became empty or full, etc.
I got some working combinations after quite some trial and error.
xclk_freq_hz | frame_size | jpeg_quality |
| 8 | FRAMESIZE_VGA | 12 |
| 12 | FRAMESIZE_VGA | 2 |
| 16 | FRAMESIZE_QQVGA | 12 |