[GH-ISSUE #7005] marked.lexer bad performance in Safari #14566

Closed
opened 2026-04-19 20:53:24 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @zeyugao on GitHub (Nov 18, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/7005

Installation Method

docker for backend, npm run dev for frontend

Environment

  • Open WebUI Version: bca9c71ed6

  • Ollama (if applicable): N/A

  • Operating System: macOS 15.1 (24B83)

  • Browser (if applicable): Safari 18.1 (20619.2.8.11.10), Chrome 130.0.6723.117

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

[Describe what you expected to happen.]

Actual Behavior:

[Describe what actually happened.]

Description

Bug Summary:

marked.lexer works bad in Safari, leading to response un-refresh due to sendPromptOpenAI update the response before the marked.lexer returns. The response refresh is discarded as result.

When rendering a relative long response, Chrome works fine

image

But safari takes a much longer time to process it

image

The previous log is printed by modifying src/lib/components/chat/Messages/Markdown.svelte

	$: (async () => {
		if (content) {
+			const startTime = performance.now();
			tokens = marked.lexer(
				replaceTokens(processResponseContent(content), model?.name, $user?.name)
			);
+			const endTime = performance.now();
+			console.log(`Processing time: ${endTime - startTime} milliseconds`);
		}
	})();

Maybe is it due to the bug of Safari https://github.com/markedjs/marked/issues/2863

So we can only try to do some mitigation to workaround it.

I propose to add a configuration to set the minimal update interval in

https://github.com/open-webui/open-webui/blob/dev/src/lib/components/chat/Chat.svelte#L1701

So that we can wait marked.lexer for some time

Reproduction Details

Steps to Reproduce:
[Outline the steps to reproduce the bug. Be as detailed as possible.]

Logs and Screenshots

Browser Console Logs:
[Include relevant browser console logs, if applicable]

Docker Container Logs:
[Include relevant Docker container logs, if applicable]

Screenshots/Screen Recordings (if applicable):
[Attach any relevant screenshots to help illustrate the issue]

Additional Information

[Include any additional details that may help in understanding and reproducing the issue. This could include specific configurations, error messages, or anything else relevant to the bug.]

Note

If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!

Originally created by @zeyugao on GitHub (Nov 18, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/7005 ## Installation Method docker for backend, `npm run dev` for frontend ## Environment - **Open WebUI Version:** https://github.com/open-webui/open-webui/commit/bca9c71ed65dbed0665ffc39f9d4ce8ee3a83b25 - **Ollama (if applicable):** N/A - **Operating System:** macOS 15.1 (24B83) - **Browser (if applicable):** Safari 18.1 (20619.2.8.11.10), Chrome 130.0.6723.117 **Confirmation:** - [ ] I have read and followed all the instructions provided in the README.md. - [ ] I am on the latest version of both Open WebUI and Ollama. - [ ] I have included the browser console logs. - [ ] I have included the Docker container logs. - [ ] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: [Describe what you expected to happen.] ## Actual Behavior: [Describe what actually happened.] ## Description **Bug Summary:** `marked.lexer` works bad in Safari, leading to response un-refresh due to `sendPromptOpenAI` update the response before the `marked.lexer` returns. The response refresh is discarded as result. When rendering a relative long response, Chrome works fine ![image](https://github.com/user-attachments/assets/80092eed-616d-4f32-b7e8-9f5eab36d2ed) But safari takes a much longer time to process it <img width="401" alt="image" src="https://github.com/user-attachments/assets/426d3565-7f30-4b02-9901-6b9d345e61cc"> The previous log is printed by modifying `src/lib/components/chat/Messages/Markdown.svelte` ```diff $: (async () => { if (content) { + const startTime = performance.now(); tokens = marked.lexer( replaceTokens(processResponseContent(content), model?.name, $user?.name) ); + const endTime = performance.now(); + console.log(`Processing time: ${endTime - startTime} milliseconds`); } })(); ``` Maybe is it due to the bug of Safari https://github.com/markedjs/marked/issues/2863 So we can only try to do some mitigation to workaround it. I propose to add a configuration to set the minimal update interval in https://github.com/open-webui/open-webui/blob/dev/src/lib/components/chat/Chat.svelte#L1701 So that we can wait `marked.lexer` for some time ## Reproduction Details **Steps to Reproduce:** [Outline the steps to reproduce the bug. Be as detailed as possible.] ## Logs and Screenshots **Browser Console Logs:** [Include relevant browser console logs, if applicable] **Docker Container Logs:** [Include relevant Docker container logs, if applicable] **Screenshots/Screen Recordings (if applicable):** [Attach any relevant screenshots to help illustrate the issue] ## Additional Information [Include any additional details that may help in understanding and reproducing the issue. This could include specific configurations, error messages, or anything else relevant to the bug.] ## Note If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#14566