Skip to content
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

[Bug]: Web client initial load is very slow (90 seconds) in Chrome (compared to Firefox - 4 seconds) #5385

Closed
cpatulea opened this issue Nov 17, 2024 · 6 comments · Fixed by #5386
Labels
bug Something isn't working

Comments

@cpatulea
Copy link
Contributor

Category

WiFi

Hardware

Heltec V3

Firmware Version

2.5.11.8e2a3e5

Description

Chrome (~90 seconds):

Screen.Recording.2024-11-17.at.2.51.14.PM.1.mov

Firefox (~4 seconds):

Screen.Recording.2024-11-17.at.2.59.48.PM.1.mov

I think this is because Chrome re-establishes the connection (TCP+TLS) for each request:
Screenshot 2024-11-17 at 3 17 12 PM

Screenshot 2024-11-17 at 3 18 42 PM

Connection keep-alive is supposed to work, and make a huge difference, as seen in Firefox, where each request takes only ~60 ms.

I thought I figured out the reason Chrome connections don't keep alive but I found some conflicting clues so now I'm not so sure I understand why.

Relevant log output

No response

@cpatulea cpatulea added the bug Something isn't working label Nov 17, 2024
@cpatulea
Copy link
Contributor Author

It does seem like it's Chrome which decides to close the connection:

Screenshot 2024-11-17 at 3 31 12 PM

@cpatulea
Copy link
Contributor Author

cpatulea commented Nov 17, 2024

Hmm, might be the preflight OPTIONS requests, which the ESP32 responds with 404 and 'Connection: close':

Screenshot 2024-11-17 at 3 36 28 PM

OPTIONS /api/v1/fromradio?all=false HTTP/1.1
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-US,en;q=0.9
Access-Control-Request-Method: GET
Access-Control-Request-Private-Network: true
Connection: keep-alive
Host: 192.168.0.190
Origin: https://client.meshtastic.org
Referer: https://client.meshtastic.org/
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

HTTP/1.1 404 Not Found
Connection: close
Content-Type: text/plain;charset=utf8

@cpatulea
Copy link
Contributor Author

@cpatulea
Copy link
Contributor Author

Recent CORS policy issue, not sure if related: meshtastic/web#249

@cpatulea
Copy link
Contributor Author

@cpatulea
Copy link
Contributor Author

Serial log during this:

[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 35 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 35 [WebServer] FromRadio=STATE_SEND_MY_INFO
DEBUG | ??:??:?? 35 [WebServer] webAPI handleAPIv1FromRadio, len 25
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 37 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 37 [WebServer] Send My NodeInfo
DEBUG | ??:??:?? 37 [WebServer] webAPI handleAPIv1FromRadio, len 92
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 38 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 38 [WebServer] Send device metadata
DEBUG | ??:??:?? 38 [WebServer] webAPI handleAPIv1FromRadio, len 37
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 40 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 40 [WebServer] webAPI handleAPIv1FromRadio, len 13
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 42 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 42 [WebServer] webAPI handleAPIv1FromRadio, len 6
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 43 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 43 [WebServer] webAPI handleAPIv1FromRadio, len 6
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)

cpatulea added a commit to cpatulea/firmware that referenced this issue Nov 17, 2024
This avoids hitting the 404 Not Found handler, which breaks connection
keep-alive, so this change fixes a big performance regression for Web Client in
Chrome: meshtastic#5385
cpatulea added a commit to cpatulea/firmware that referenced this issue Nov 17, 2024
This avoids hitting the 404 Not Found handler, which breaks connection
keep-alive, so this change fixes a big performance regression for Web Client in
Chrome: meshtastic#5385

Tested on Heltec V3.
fifieldt pushed a commit to cpatulea/firmware that referenced this issue Nov 19, 2024
This avoids hitting the 404 Not Found handler, which breaks connection
keep-alive, so this change fixes a big performance regression for Web Client in
Chrome: meshtastic#5385

Tested on Heltec V3.
caveman99 pushed a commit to cpatulea/firmware that referenced this issue Nov 19, 2024
This avoids hitting the 404 Not Found handler, which breaks connection
keep-alive, so this change fixes a big performance regression for Web Client in
Chrome: meshtastic#5385

Tested on Heltec V3.
thebentern added a commit that referenced this issue Nov 19, 2024
This avoids hitting the 404 Not Found handler, which breaks connection
keep-alive, so this change fixes a big performance regression for Web Client in
Chrome: #5385

Tested on Heltec V3.

Co-authored-by: Ben Meadors <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant