[PR #20908] [CLOSED] fix: improve performance and fix memory leaks #25823

Closed
opened 2026-04-20 06:08:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20908
Author: @sjhddh
Created: 1/23/2026
Status: Closed

Base: mainHead: fix/performance-and-memory-leaks


📝 Commits (1)

  • b5261d8 fix: improve performance and fix memory leaks

📊 Changes

9 files changed (+50 additions, -30 deletions)

View changed files

📝 backend/open_webui/routers/images.py (+2 -1)
📝 backend/open_webui/routers/pipelines.py (+25 -14)
📝 src/lib/components/workspace/Prompts.svelte (+1 -1)
📝 src/lib/components/workspace/Tools.svelte (+1 -1)
📝 src/lib/components/workspace/common/AccessControl.svelte (+2 -2)
📝 src/lib/components/workspace/common/MemberSelector.svelte (+2 -2)
📝 src/lib/components/workspace/common/TagSelector.svelte (+1 -1)
📝 src/lib/components/workspace/common/ViewSelector.svelte (+1 -1)
📝 src/routes/+layout.svelte (+15 -7)

📄 Description

Summary

This PR improves application performance and stability through targeted optimizations in both frontend and backend:

Frontend

  • Fix memory leaks in +layout.svelte: The onMount hook was adding event listeners for message, touchstart, touchmove, touchend, and visibilitychange but only cleaning up resize. This causes memory leaks during navigation and hot-reloads. Now all listeners are properly cleaned up.
  • Add keys to {#each} blocks: Added unique keys to 6 components (ViewSelector, TagSelector, MemberSelector, AccessControl, Tools, Prompts) to enable efficient DOM diffing instead of full re-renders.

Backend

  • Parallelize image loading: Changed sequential [await load_url_image(img) for img in ...] to asyncio.gather() in image_edits endpoint, significantly reducing latency for multi-image edits.
  • Unblock async event loop: Wrapped all synchronous requests calls in pipelines.py with asyncio.to_thread() to prevent blocking the FastAPI event loop during external API calls.

Test plan

  • Verify frontend components render correctly after keyed {#each} changes
  • Test touch-to-refresh behavior on mobile still works
  • Test pipeline upload/add/delete operations still function
  • Test image editing with multiple images

Contributor License Agreement

I have read and agree to the Contributor License Agreement.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/20908 **Author:** [@sjhddh](https://github.com/sjhddh) **Created:** 1/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/performance-and-memory-leaks` --- ### 📝 Commits (1) - [`b5261d8`](https://github.com/open-webui/open-webui/commit/b5261d89bb62d72e8f52f968e8449e03071c7b2c) fix: improve performance and fix memory leaks ### 📊 Changes **9 files changed** (+50 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/images.py` (+2 -1) 📝 `backend/open_webui/routers/pipelines.py` (+25 -14) 📝 `src/lib/components/workspace/Prompts.svelte` (+1 -1) 📝 `src/lib/components/workspace/Tools.svelte` (+1 -1) 📝 `src/lib/components/workspace/common/AccessControl.svelte` (+2 -2) 📝 `src/lib/components/workspace/common/MemberSelector.svelte` (+2 -2) 📝 `src/lib/components/workspace/common/TagSelector.svelte` (+1 -1) 📝 `src/lib/components/workspace/common/ViewSelector.svelte` (+1 -1) 📝 `src/routes/+layout.svelte` (+15 -7) </details> ### 📄 Description ## Summary This PR improves application performance and stability through targeted optimizations in both frontend and backend: ### Frontend - **Fix memory leaks in `+layout.svelte`**: The `onMount` hook was adding event listeners for `message`, `touchstart`, `touchmove`, `touchend`, and `visibilitychange` but only cleaning up `resize`. This causes memory leaks during navigation and hot-reloads. Now all listeners are properly cleaned up. - **Add keys to `{#each}` blocks**: Added unique keys to 6 components (`ViewSelector`, `TagSelector`, `MemberSelector`, `AccessControl`, `Tools`, `Prompts`) to enable efficient DOM diffing instead of full re-renders. ### Backend - **Parallelize image loading**: Changed sequential `[await load_url_image(img) for img in ...]` to `asyncio.gather()` in `image_edits` endpoint, significantly reducing latency for multi-image edits. - **Unblock async event loop**: Wrapped all synchronous `requests` calls in `pipelines.py` with `asyncio.to_thread()` to prevent blocking the FastAPI event loop during external API calls. ## Test plan - [ ] Verify frontend components render correctly after keyed `{#each}` changes - [ ] Test touch-to-refresh behavior on mobile still works - [ ] Test pipeline upload/add/delete operations still function - [ ] Test image editing with multiple images --- ## Contributor License Agreement I have read and agree to the [Contributor License Agreement](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:08:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#25823