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

Attempting to preview certain links will leave the previewer Regex running and unable to cancel #113

Open
pocketlim opened this issue Mar 17, 2020 · 4 comments

Comments

@pocketlim
Copy link

pocketlim commented Mar 17, 2020

Hey Leonardo Cardoso! Just wanted to say big thank you to a cool little kit of code making it really easy to get a preview of a URL! ❤️

Certain links, however, will cause the previewer to get down to the Regex.pregMatchAll() method and there it will churn pretty much indefinitely, tasking one of the cores to maximum. Because it's already beyond the request part, it's unable to be cancelled at that point. It will continue to task the CPU as you navigate around the app, but at least it stops when the app is backgrounded.

Example URL: https://news.ycombinator.com/item?id=22598009

Screen Shot 2020-03-16 at 8 54 43 PM

Would you have any suggestion on how to handle a case like this, or a way/means to cancel the churning after a specific amount of time has passed?

For now, I will try and collect bad URLs and just avoid sending them to the previewer

Here's a sample project to test with:

LinkPreviewHighCPUStuck-CancelAdded.zip

(Edit: Updated with a version that doesn't use a cache, and with cancel button)
I know, it's crude, but it tests one working link preview and the bad link.

Xcode: 11.3.1
iOS targeted: 11.x, 12.x, 13.x
Stack trace and time graph shown above

Let me know if you'd like any more help.

@inPhilly
Copy link

@pocketlim is this still an issue or have you found a way to fix it?

@pocketlim
Copy link
Author

Unfortunately, no, it is still happening as far as I know. I am blacklisting the URLs that I found that aren't working or that cause issues so far.

@LeonardoCardoso
Copy link
Owner

Thanks for the detailed report. I will add it to investigation needed.

@huanghui1998hhh
Copy link

I'm facing this, it's still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants