esp-idf: Network "out of memory" error (IDFGH-2154)

Environment

  • Development Kit: ESP-EYE
  • Module or chip used: ESP32-WROOM-32
  • IDF version: v4.1-dev-369-g4dac7c7df
  • Build System: Make
  • Compiler version: 8.2.0
  • Operating System: macOS
  • Power Supply: USB

Problem Description

I’m developing a HomeKit IP camera based on various ESP32-CAM modules (in this particular case I am testing on ESP-EYE). Part of the functionality includes streaming live H.264 encoded video with RTP protocol. The protocol is based on UDP. At the time of streaming there is also at least one TCP connection open (for HomeKit management). The problem I’m having is: when stream starts it obviously sends UDP packets (<1400 bytes) at some rate. Sometimes a after sending several dozens packets sendto() call fails with errno 12 (Out of memory) and after that the whole system becomes unresponsive over network and device needs to be rebooted. What’s odd is that sometimes it works and I am able to start and stop streaming sessions multiple times. It feels it’s not only about UDP, it’s a combination of factors (UDP + TCP + high load on CORE1 maybe?). Though sometimes it works just fine and it seems that it is somehow determined on first stream: if first stream works, subsequent streams will work as well. I tested it multiple times and when it does not hang on first stream, it works every stream. If it fails on first stream though, you can not continue testing as it becomes unresponsive over network.

Expected Behavior

Network calls do not fail with an error. Module continue to be accessible via network.

Actual Behavior

Network API call (sendto()) fails with errno 12 (Out of memory) and module stops responding via network.

Steps to repropduce

  1. Build esp32-homekit-camera firmware using settings described in README.
  2. Flash firmware to ESP-EYE module.
  3. Use iOS device (iPhone), run Home app (builtin), add accessory, locate accessory in list of available accessories, use setup code (password) “111-11-111”.
  4. Verify that it shows camera connected (blue dot at top right corner of it’s frame).
  5. Click on the camera frame to start live stream. Expected to have camera stream live showing live footage. If stream works fine, reboot module, wait for it too boot and try starting live stream again. Monitor console output for error like “Failed to send encrypted packet (code 12)”.

Debug Logs

There are no crashes per se, it’s just returns error on API call and at the same time stops any (visible) network activity.

Other items if possible

  • sdkconfig file (attach the sdkconfig file from your project folder)
  • elf file in the build folder (note this may contain all the code details and symbols of your project.)
  • coredump (This provides stacks of tasks.)

sdkconfig.zip

esp32-homekit-camera.zip

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Hi @maximkulkin ,

This looks very similar to #3592. The root cause is that Wi-Fi can’t use all of the internal memory correctly, and a fix for this is being merged soon (the issue thread has some examples of fixes you can make in IDF, in the meantime). There is a secondary issue that this error message reports internal+external free heap, but only internal memory is full.