Skip to content

remove 2048 byte clipboard limit for macos #2087

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

Closed
wants to merge 5 commits into from
Closed

Conversation

kpym
Copy link
Contributor

@kpym kpym commented Sep 29, 2024

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
Member

Thanks! this is very much needed! 💯

@smeech
Copy link
Collaborator

smeech commented Sep 29, 2024

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
Copy link
Contributor

woerndl commented Oct 6, 2024

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
Copy link
Member

AucaCoyan commented Oct 6, 2024

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
Copy link
Contributor

woerndl commented Oct 17, 2024

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
Copy link
Contributor

woerndl commented Oct 26, 2024

I can confirm this also works in macOS 15.0.1.

@AucaCoyan
Copy link
Member

AucaCoyan commented Mar 6, 2025

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