Repository navigation
perf: stop TLS retry storm, stream-parse JSON with a filter - #94
Merged
MatixYo merged 1 commit intoSep 24, 2026
Merged
Conversation
The 200 ms connect timeout was too short for a TLS handshake, so every poll retried handshakes in a loop until the 10 s deadline. Use a 5000 ms connect timeout and a single attempt; a stalled connect is retried by the next poll instead of blocking the UI. Parse the response straight off the socket with a DeserializationOption Filter that keeps only the rendered fields, instead of buffering the whole body into a String and parsing that. Drop performGetWithPoll and readResponseBodyWithPoll in favor of one httpGetJson helper. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qjXYQiTkbgyVV7ZzvKzA3
MatixYo
approved these changes
Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two problems in the ADS-B fetch path, both visible as UI stalls on an ESP32-C3.
TLS retry storm. The connect timeout was 200 ms — far too short for a TLS handshake to opendata.adsb.fi.
performGetWithPolltherefore almost always failed and retried in a tight loop until the 10 s request deadline, opening a fresh handshake each time. Every poll cycle burned seconds of CPU and heap on handshakes that were killed just before they could finish. Now: 5000 ms connect timeout and a single attempt (kConnectAttempts = 1). If a connect stalls, the poll cycle gives up and the next one retries 3 s later, rather than blocking the display. ThepollNetwork()call before the GET is kept.Whole response buffered as a String.
readResponseBodyWithPollaccumulated the entire JSON body into a heapString, which was then parsed into aJsonDocument— the payload existed twice in RAM, and a busy sector's response is large. Replaced withdeserializeJson(doc, http.getStream(), DeserializationOption::Filter(filter)): ArduinoJson parses straight off the socket and the filter keeps only the fields actually rendered (lat,lon, headings, speeds, altitudes,flight,hex,t,category). No intermediate String, and the document holds a small fraction of the response.Also: request timeout 10000 ms to 6000 ms, and the now-unused
performGetWithPoll/readResponseBodyWithPollare deleted. The two paths are consolidated into onehttpGetJsonhelper.User impact: the radar stops freezing for seconds at a time on flaky WiFi, and peak heap use during a fetch drops substantially — the difference between working and heap-exhausting when many aircraft are in range.
Tested: builds for env:supermini; ran on an ESP32-C3 Super Mini + GC9A01 (combined with other local changes).
🤖 Generated with Claude Code
https://claude.ai/code/session_017qjXYQiTkbgyVV7ZzvKzA3