Skip to content

remove 2048 byte clipboard limit for macos - #2087

Closed
kpym wants to merge 5 commits into
espanso:devfrom
kpym:dev
Closed

kpym wants to merge 5 commits into
espanso:devfrom
kpym:dev

Conversation

@kpym

@kpym kpym commented Sep 29, 2024

Copy link
Copy Markdown
Contributor

This PR aims to resolve #1612 and #2051 on macOS by replacing the previously hardcoded 2048-character clipboard size with an adaptive size based on the actual clipboard content length.

Note: This pull request is untested on macOS.
Unfortunately, I do not have access to a macOS environment at the moment, but I believe this solution should address the issue. Testing is necessary before merging.

This change is similar to the fix in #2085, with the key difference being in the native code for clipboard_get_length. The logic mirrors that of clipboard_get_text, except it uses strlen instead of strncpy to determine the required length.

Please ensure that the code is tested on macOS before proceeding with the merge.

@smeech
smeech marked this pull request as draft September 29, 2024 13:27
@AucaCoyan

Copy link
Copy Markdown
Collaborator

Thanks! this is very much needed! 💯

@smeech

smeech commented Sep 29, 2024

Copy link
Copy Markdown
Collaborator

I marked this as Draft, pending macOS etc. testing.

Should this branch become Main so that testing can take place with a Dev branch? The Main branch is very out of date, and I'm not sure it serves a useful purpose?

@woerndl

woerndl commented Oct 6, 2024

Copy link
Copy Markdown
Contributor

I can confirm this fix works on macOS 14.6.1, also tested with larger chunks of text and edge cases like this.

My attempts to use less memory, explicitly use autoreleasepool and to run on the main thread didn't improve stability or memory usage. Virtual memory fills up with this solution, just as it does with mine. Real and private memory are released with this solution, just as with mine.

@AucaCoyan

AucaCoyan commented Oct 6, 2024 •

Copy link
Copy Markdown
Collaborator

Good! I see this good in general sense. I have only one question, is this PR opening a bug about memory or the bug already exists? This is what is not clear to me (sorry for being so out of the loop!)

My attempts to use less memory, explicitly use autoreleasepool and to run on the main thread didn't improve stability or memory usage. Virtual memory fills up with this solution, just as it does with mine. Real and private memory are released with this solution, just as with mine.

@woerndl

woerndl commented Oct 17, 2024

Copy link
Copy Markdown
Contributor

The bug, or more likely bugs, already exist: #1675. I’d say it is not solely related to the keystrokes, as mentioned by Federico in the issue. When you copy and paste large clipboards (which you can now do, thanks to this PR), you can see the virtual memory growing with each repetition, and it doesn't get freed correctly.

@AucaCoyan
AucaCoyan self-requested a review October 19, 2024 11:56
@woerndl

woerndl commented Oct 26, 2024

Copy link
Copy Markdown
Contributor

I can confirm this also works in macOS 15.0.1.

@AucaCoyan

AucaCoyan commented Mar 6, 2025 •

Copy link
Copy Markdown
Collaborator

Superseded by #2089 . Just a coincidence that were two very similar approaches 🤞🏼 .
Thank you very much for your effort!

@AucaCoyan AucaCoyan closed this Mar 6, 2025
@AucaCoyan
AucaCoyan removed their request for review March 6, 2025 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MacOS - Clipboard seem to be limited to 2048 characters

4 participants