-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Fix captive_portal
loading entire web_server
#9066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hey there @dentra, mind taking a look at this pull request as it has been labeled with an integration ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR prevents the captive_portal
component from unintentionally pulling in the full web_server
by removing automatic loading and guarding web-server–specific code behind a compile flag.
- Removed
AUTO_LOAD = ["web_server"]
from the IDF wrapper to break the unwanted dependency. - Wrapped all web-server–dependent declarations and implementations in
#ifdef USE_WEBSERVER
. - Added
defines.h
include to support the new compile-time flag.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
esphome/components/web_server_idf/init.py | Removed the AUTO_LOAD directive that caused web_server to load by default. |
esphome/components/web_server_idf/web_server_idf.h | Added #ifdef USE_WEBSERVER guards around web-server–only declarations; included defines.h . |
esphome/components/web_server_idf/web_server_idf.cpp | Wrapped web-server includes and AsyncEventSource /response implementations in #ifdef USE_WEBSERVER . |
Comments suppressed due to low confidence (2)
esphome/components/web_server_idf/init.py:10
- Add tests to verify that
web_server_idf
compiles and operates correctly both with and without theweb_server
component (i.e., whenUSE_WEBSERVER
is undefined) to prevent future regressions.
-AUTO_LOAD = ["web_server"]
esphome/components/web_server_idf/web_server_idf.h:1
- [nitpick] Consider adding a brief file-level comment explaining that parts of this header are conditionally compiled under
USE_WEBSERVER
, so maintainers understand the purpose of the guards.
#pragma once
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! 🍻
Thanks |
captive_portal
loading entire web_server
captive_portal
loading entire web_server
What does this implement/fix?
Quick description
This PR fixes an issue where the
captive_portal
component automatically includes the fullweb_server
component when using the ESP-IDF framework, causing unnecessary binary size increase.This PR fixes a regression introduced in PR #7538 where the
web_server_idf
component was set to automatically load the fullweb_server
component. This caused thecaptive_portal
component to inadvertently include the web server functionality when using ESP-IDF framework, significantly increasing binary size.Root Cause
The
captive_portal
component depends onweb_server_base
, which conditionally loadsweb_server_idf
when using ESP-IDF. Theweb_server_idf
component hadAUTO_LOAD = ["web_server"]
, creating an unwanted dependency chain:Solution
AUTO_LOAD = ["web_server"]
directive fromweb_server_idf/__init__.py
#ifdef USE_WEBSERVER
) around web_server-specific code inweb_server_idf
to ensure it compiles correctly both with and without the web_server componentChanges Made
AUTO_LOAD = ["web_server"]
#ifdef USE_WEBSERVER
guards around:web_server::WebServer
andweb_server::ListEntitiesIterator
AsyncEventSource
andAsyncEventSourceResponse
class declarationsDeferredEvent
struct andmessage_generator_t
type definitionDefaultHeaders
class#ifdef USE_WEBSERVER
guards around:AsyncEventSource
andAsyncEventSourceResponse
method implementationsTesting
captive_portal
alone no longer includesweb_server
componentweb_server
still works correctlyUSE_WEBSERVER
is only defined whenweb_server
component is explicitly includedTypes of changes
Related issue or feature (if applicable): fixes esphome/issues#6883 fixes esphome/issues#7112
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: