J. Nick Koston
c2968e64d1
Merge branch 'esp32_cam_init_order' into frame_helper_optimize_cleanup_api
2025-05-15 16:51:59 -05:00
J. Nick Koston
db9a070c42
Fix ESP32 Camera class inheritance
...
panic was introduced in bb1f24ab43
Fix ESP32 Camera crash by reordering parent class inheritance to match other entity components. The crash occurred because `EntityBase` methods were accessed before initialization when Component was the first parent. Changing ESP32Camera to inherit first from EntityBase ensures proper memory layout and initialization order, consistent with all other entities in the codebase.
```
[14:39:21][D][binary_sensor:032]: 'esp-cam status': Sending state ON
[14:39:21][D][api.connection:1527]: Home Assistant 2025.6.0.dev0 (192.168.209.64): Connected successfully
[14:39:21]Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
[14:39:21]
[14:39:21]Core 1 register dump:
[14:39:21]PC : 0x4008aa94 PS : 0x00060d30 A0 : 0x800d40eb A1 : 0x3ffc06a0
WARNING Decoded 0x4008aa94: strlen at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:46
[14:39:21]A2 : 0x00000027 A3 : 0x00000023 A4 : 0x000000ff A5 : 0x0000ff00
[14:39:21]A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x800d4982 A9 : 0x3ffc0670
[14:39:21]A10 : 0x3ffc0728 A11 : 0x3ffc07f0 A12 : 0x00000006 A13 : 0x00000000
[14:39:21]A14 : 0x3ffb5e64 A15 : 0x00000000 SAR : 0x00000019 EXCCAUSE: 0x0000001c
[14:39:21]EXCVADDR: 0x00000027 LBEG : 0x4008a350 LEND : 0x4008a36c LCOUNT : 0xffffffff
[14:39:21]
[14:39:21]
[14:39:21]Backtrace: 0x4008aa91:0x3ffc06a0 0x400d40e8:0x3ffc06b0 0x400e64ea:0x3ffc06d0 0x400d4b2d:0x3ffc0710 0x400d5e0e:0x3ffc0760 0x400d47df:0x3ffc0830 0x400d484a:0x3ffc0870 0x400da2cd:0x3ffc08a0 0x400e6319:0x3ffc08c0 0x400d5134:0x3ffc08e0
0x400da244:0x3ffc0980 0x401669e5:0x3ffc0a60 0x40166a9d:0x3ffc0a80 0x400e4c1f:0x3ffc0aa0 0x400e7446:0x3ffc0ad0 0x400da78a:0x3ffc0af0
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x4008aa91: strlen at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:43
WARNING Decoded 0x400d40e8: std::char_traits<char>::length(char const*) at /Users/bdraco/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/12.2.0/bits/char_traits.h:395
(inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> >(char const*, std::allocator<char> const&) at
/Users/bdraco/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/12.2.0/bits/basic_string.h:641
WARNING Decoded 0x400e64ea: esphome::EntityBase::get_object_id[abi:cxx11]() const at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/core/entity_base.cpp:53
WARNING Decoded 0x400d4b2d: esphome::api::get_default_unique_id(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, esphome::EntityBase*) at
/Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/api/api_connection.cpp:256
WARNING Decoded 0x400d5e0e: esphome::api::APIConnection::try_send_camera_info_(esphome::esp32_camera::ESP32Camera*) at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/api/api_connection.cpp:1139 (discriminator 1)
WARNING Decoded 0x400d47df: esphome::api::APIConnection::send_info_(esphome::EntityBase*, bool (esphome::api::APIConnection::*)(void*)) at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/api/api_connection.h:478
(discriminator 6)
WARNING Decoded 0x400d484a: esphome::api::APIConnection::send_camera_info(esphome::esp32_camera::ESP32Camera*) at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/api/api_connection.cpp:1134 (discriminator 4)
WARNING Decoded 0x400da2cd: esphome::api::ListEntitiesIterator::on_camera(esphome::esp32_camera::ESP32Camera*) at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/api/list_entities.cpp:81
WARNING Decoded 0x400e6319: esphome::ComponentIterator::advance() at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/core/component_iterator.cpp:170
WARNING Decoded 0x400d5134: esphome::api::APIConnection::loop() at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/api/api_connection.cpp:163
WARNING Decoded 0x400da244: esphome::api::APIServer::loop() at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/api/api_server.cpp:148
WARNING Decoded 0x401669e5: esphome::Component::call_loop() at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/core/component.cpp:80
WARNING Decoded 0x40166a9d: esphome::Component::call() at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/core/component.cpp:107
WARNING Decoded 0x400e4c1f: esphome::Application::loop() at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/core/application.cpp:75
WARNING Decoded 0x400e7446: loop() at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/cam-utilities-indoor.yaml:54
WARNING Decoded 0x400da78a: esphome::loop_task(void*) at /Users/bdraco/esphome/.esphome/build/cam-utilities-indoor/src/esphome/components/esp32/core.cpp:79 (discriminator 1)
```
2025-05-15 15:24:29 -05:00
J. Nick Koston
4bff8ef969
Revert "Bail quickly if there is no data to read"
...
This reverts commit e544f6711e .
2025-05-15 13:43:28 -05:00
J. Nick Koston
9ff93142fd
Revert "FIONREAD"
...
This reverts commit 2201f67045 .
2025-05-15 13:42:49 -05:00
J. Nick Koston
a4c5384b30
Revert "preen"
...
This reverts commit b5af2cb4ee .
2025-05-15 13:42:48 -05:00
J. Nick Koston
b5af2cb4ee
preen
2025-05-15 13:32:12 -05:00
J. Nick Koston
29b3d7355c
Merge branch 'bail_no_data' into frame_helper_optimize_cleanup_api
2025-05-15 13:27:19 -05:00
J. Nick Koston
2201f67045
FIONREAD
2025-05-15 13:26:59 -05:00
J. Nick Koston
7a364ff63a
cleanup
2025-05-15 12:54:34 -05:00
J. Nick Koston
e544f6711e
Bail quickly if there is no data to read
2025-05-15 12:54:34 -05:00
J. Nick Koston
31f5bbf623
cleanup
2025-05-15 12:52:25 -05:00
J. Nick Koston
488dc40f2e
Bail quickly if there is no data to read
2025-05-15 12:48:33 -05:00
J. Nick Koston
e8e0e34702
Merge branch 'multi_task_logger_esp32' into frame_helper_optimize_cleanup_api
2025-05-15 11:02:49 -05:00
J. Nick Koston
eebdc9c38f
Fix ESP32 console logging corruption and message loss in multi-task environments
...
These changes enhance ESPHome's logging system on ESP32 multi-task environments:
1. **Emergency Console Logging**:
- Added fallback console logging when the task log buffer is full or disabled
- Ensures critical messages are still visible even when the ring buffer fails
2. **Improved Console Output**:
- Messages successfully sent to the ring buffer now also display on the console
- Ensures consistent console output for all log messages regardless of source
3. **Optimized Resource Usage**:
- Release ring buffer messages earlier after transferring to tx_buffer
- Reduces contention for the shared log buffer in multi-task environments
1. **Stack Memory Efficiency**:
- No longer need to allocate stack memory for console output when ring buffer is available
- Only uses stack memory for emergency fallback cases, reducing stack usage in normal operation
2. **Console Output Integrity**:
- Prevents console output corruption that could occur with concurrent writes from multiple tasks
- Serializes all console output through the main loop when possible
3. **Message Ordering**:
- Messages from different tasks may appear slightly out of order due to async delivery to main loop
- This trade-off is preferable to corrupted console output from concurrent writes
These improvements provide more reliable logging behavior, particularly under memory constraints or high logging volume, while maintaining thread safety and minimizing resource contention.
2025-05-15 10:52:58 -05:00
Thomas Rupprecht
4761ffe023
[gps] update lib, improve code/tests/config ( #8768 )
2025-05-15 22:07:41 +12:00
Thomas Rupprecht
88edddf07a
[log] improve/refactor log ( #8708 )
2025-05-15 21:45:07 +12:00
J. Nick Koston
0b77cb1d16
Logger Recursion Guard per Task on ESP32 ( #8765 )
2025-05-15 21:36:28 +12:00
J. Nick Koston
65b6d256bc
Merge branch 'implement_buffer_queue' into frame_helper_optimize_cleanup_api
2025-05-15 03:52:34 -05:00
J. Nick Koston
428371d685
preen
2025-05-15 03:51:08 -05:00
J. Nick Koston
d108219947
dry
2025-05-15 03:49:51 -05:00
J. Nick Koston
cdf3ed07ba
dry
2025-05-15 03:47:10 -05:00
J. Nick Koston
061bbabd09
Merge branch 'implement_buffer_queue' into frame_helper_optimize_cleanup_api
2025-05-15 03:25:02 -05:00
J. Nick Koston
2646ec166b
save some bytes
2025-05-15 03:24:47 -05:00
J. Nick Koston
bafc57f02e
fix refactoring error
2025-05-15 03:06:52 -05:00
J. Nick Koston
549ed6178b
fix refactoring error
2025-05-15 03:06:36 -05:00
J. Nick Koston
0c67e06573
Merge branch 'implement_buffer_queue' into frame_helper_optimize_cleanup_api
2025-05-15 03:02:16 -05:00
J. Nick Koston
592a95c565
dry
2025-05-15 02:58:15 -05:00
J. Nick Koston
f41ef68b41
dry
2025-05-15 02:55:00 -05:00
J. Nick Koston
26af1cf650
preen
2025-05-15 02:32:19 -05:00
J. Nick Koston
66b995cffe
cleanups
2025-05-15 02:13:20 -05:00
J. Nick Koston
5d0b74db3d
Merge branch 'implement_buffer_queue' into frame_helper_optimize_cleanup_api
2025-05-15 01:54:52 -05:00
J. Nick Koston
31e3065600
fixes
2025-05-15 01:49:38 -05:00
J. Nick Koston
872a70d235
fixes
2025-05-15 01:48:43 -05:00
J. Nick Koston
7b84eb2903
fixes
2025-05-15 01:47:18 -05:00
J. Nick Koston
7b4e7108c0
cleanup
2025-05-15 01:45:24 -05:00
J. Nick Koston
d4b42ebf20
Eliminate outbound buffer expensive O(n) with O(1) queue operations
...
- Replaced inefficient vector-based buffer with a queue of discrete message buffers
- Moved common code to base class to reduce duplication
- Removed unnecessary data copying after partial sends
- Added small-buffer optimization to allow writing with backlog <256 bytes
- Moved common code to base class to reduce duplication
2025-05-15 01:31:43 -05:00
J. Nick Koston
a8e9c79975
Eliminate outbound buffer expensive O(n) with O(1) queue operations
...
- Replaced inefficient vector-based buffer with a queue of discrete message buffers
- Moved common code to base class to reduce duplication
- Removed unnecessary data copying after partial sends
- Added small-buffer optimization to allow writing with backlog <256 bytes
- Moved common code to base class to reduce duplication
2025-05-15 01:31:22 -05:00
J. Nick Koston
efa6745a5e
Optimize protobuf varint decoder for ESPHome use case ( #8791 )
2025-05-15 17:16:25 +12:00
J. Nick Koston
dd8d8ad952
Use fixed buffer for plaintext protocol like noise protocol ( #8800 )
2025-05-15 17:16:08 +12:00
dependabot[bot]
57284b1ac3
Bump cairosvg from 2.8.0 to 2.8.1 ( #8799 )
...
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-14 23:26:28 -05:00
J. Nick Koston
47b9c3db1d
adjust
2025-05-14 23:09:18 -05:00
J. Nick Koston
b32ed848b0
Merge remote-tracking branch 'upstream/dev' into frame_helper_optimize_cleanup_api
2025-05-14 23:08:09 -05:00
Jesse Hills
1a651ce66d
Update some sensor schemas to be Optional ( #8803 )
2025-05-15 02:40:11 +00:00
Jesse Hills
730441c120
[api] Update api proto to add legacy value ( #8802 )
2025-05-14 21:26:21 -05:00
J. Nick Koston
bb1f24ab43
Avoid protobuf message construction when tx buffer is full ( #8787 )
...
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com >
2025-05-14 21:25:44 -05:00
J. Nick Koston
8fb68804e4
Merge branch 'cleanup_api' into frame_helper_optimize_cleanup_api
2025-05-14 17:28:29 -05:00
J. Nick Koston
e2453dd513
optimize
2025-05-14 17:27:05 -05:00
J. Nick Koston
ed563b0c83
Merge branch 'cleanup_api' into frame_helper_optimize_cleanup_api
2025-05-14 17:20:38 -05:00
J. Nick Koston
856d679ce2
Merge branch 'plaintext' into frame_helper_optimize
2025-05-14 16:58:59 -05:00
J. Nick Koston
f5ac77634b
Use fixed buffer for plaintext protocol like noise protocol
...
This PR optimizes memory usage in the APIPlaintextFrameHelper by replacing the vector-based header buffer with a fixed-size buffer, similar to what's already done in the noise protocol implementation.
- Replaced `std::vector<uint8_t> rx_header_buf_` with a 5-byte fixed buffer `uint8_t rx_header_buf_[5]`
- Implemented a modified protocol parsing algorithm that validates the indicator byte without storing it
- Ensured compatibility with noise protocol by supporting message sizes up to at least 65535 (requires 3-byte varint)
- Improved readability with clearer conditional logic and better comments
- Added detailed notes about protocol limitations and variable length encoding
- Reduces memory fragmentation by eliminating dynamic allocations during header parsing
2025-05-14 16:48:12 -05:00