Copy and paste takes 56 seconds to complete
If you copy the contents of this, it thinks that there are URLs in it, which it all tries to resolve. Also the Regex can't complete within time giving errors.
Example errors:
System.Net.Sockets.SocketException (0x80004005): No such host is known
System.Text.RegularExpressions.RegexMatchTimeoutException: The RegEx engine has timed out while trying to match a pattern to an input string. This can occur for many reasons, including very large inputs or excessive backtracking caused by nested quantifiers, back-references and other factors.
There are probably two things that needs to be done:
- Make all copy parsers / things async, don't lock / capture the clipboard, so the user can still paste it
- Better / faster regex (with async a little less important)
- Distinct list of URLs, so it might only be one url a 100 times or so (I didn't check how it is implemented right now)
I see it checks IsValidDomainAsync a lot of times for "Shapeshifter.exe" 😇
We should use https://github.com/0xcb/Re2.Net instead of C# Regular Expressions. RE2 is Google's regular expression library which is guaranteed to not go to an infinite loop and is secure to use.
The parsers should already be async, so that's a mistake if they are not.
Yes, I see the whole parsing in itself is async, and also with yield, very good. I think it just captures the clipboard also while doing all this in async. So you cannot use the clipboard until Shapeshifter is done.
The thing is that we can never know if something is a website or not. So what Shapeshifter will try to do is to make a DNS resolve of all words in the clipboard to detect possible URLs to open. That should be very fast.
The errors you are seeing, are you sure they aren't just "first chance" exceptions? Those are exceptions that are actually caught, but displayed anyway while debugging.
You are right about the first chance exceptions, and also luckily, else we have a lot of issues on Github 🚀
They have no NuGet package apparently. I have asked them to create one.
https://github.com/0xcb/Re2.Net/issues/4
@KoalaBear84 I have trimmed the logs heavily in the latest pre-release that is up in half an hour or so (or you can pull latest develop now and see). I also disabled first-chance exceptions from popping up.
See if it makes debugging easier, and thank you so much for helping me debug!
This should be switched to the time of copying and then persisted, instead of being generated dynamically upon switching to the item. That would solve a lot.
I now greatly improved the regex performance by switching to RE2, but still leaving this here, as generating actions should never delay clipboard performance.
True, it should leave the clipboard completely untouched for the current item and should only change something when you really use an item from the past. I don't know if that is possible? So when you do CTRL + C and just CTRL + V without holding it AND selecting a previous item, it should not touch the clipboard, otherwise than reading it, in async/locking if possible. But the last thing I don't know if that is possible.
While that may be faster, it is only faster in the scenario where you don't switch. I would much rather force the data through the same funnel always for consistency.
Here's what I'll do:
- When copying something, it'll start analyzing the data in the background to determine what kind of actions are available for that data. It will do this in an asynchronously queued manner.
- Once the analysis for an action is done, that action gets added to the list of available actions for that item.
- When the user shows the UI, we only display the actions that have finished analyzing for each item. So if one action is slow to analyze, the user just won't see that action.
This way, the user can always copy and switch right away, and because the data is not analyzed upon showing the UI but instead in the background when a new item has been copied, it should also feel faster.
Does that make sense?
Yes. I think point 2 is already working, at least a little. When I tried it back then, the 'Open URLs' action was not yet shown, but after a couple of seconds it WAS, dynamically, while the overlay was open.
Can you see if the latest prerelease improves the performance? It really should. Issue should still be present though.
Hmmm it is actually equally bad if not worse now. I opened #541 in addition to this to improve upon it.
I didn't test it yet. But I guess indeed it will not make that much of a difference. It also is now because of the wrong data being scanned, and that results in an immense list of domains it wants to scan, and that takes a very long time.
All link related actions have now been entirely disabled until we stabilize all of this. There is no reason for it degrading the experience given how much they are used.
Prerelease up in a few minutes.
@KoalaBear84 how is the latest prerelease performing? It should be significantly better, but there is still work to be done.
This has now been fixed. Deferred action resolving has been implemented, and it's insanely fast and effective.
Great. Will check it out.
Be sure to download it manually though because latest prereleases still have issues auto updating.
Hmm, I did. shapeshifter-v6.2018.606.2854. It instantly crashes.
Also cleaned C:\Program Files\Shapeshifter and also tried to put Shapeshifter.exe directly in the right folder. But unfortunately nothing helps, cannot start it. Crash dump is generated.
Running it from the installation folder is not a good idea. Try cleaning the installation folder and removing it entirely, then run the downloaded file.
Yes, I did that. Hmm, this is strange. But now I also deleted C:\Program Files\Shapeshifter and it works.
Hmm. I just copied 193 kB of a Shapeshifter log file. And eventually it showed the "Shapeshifter is not responding".
2018-06-08 12:14:57.115 [#15868] [Shapeshifter.WindowsDesktop.Infrastructure.Handles.Factories.PerformanceHandleFactory] [VRB]
Finished executing HasLinkWithConditionsAsync in 6589.7254 milliseconds.
2018-06-08 12:15:03.581 [#15868] [Shapeshifter.WindowsDesktop.Infrastructure.Handles.Factories.PerformanceHandleFactory] [VRB]
Finished executing HasLinkWithConditionsAsync in 6466.6556 milliseconds.
2018-06-08 12:15:10.127 [#15868] [Shapeshifter.WindowsDesktop.Infrastructure.Handles.Factories.PerformanceHandleFactory] [VRB]
Finished executing HasLinkWithConditionsAsync in 6545.4271 milliseconds.
2018-06-08 12:16:06.474 [#15868] [Shapeshifter.WindowsDesktop.Infrastructure.Handles.Factories.PerformanceHandleFactory] [VRB]
Finished executing HasLinkWithConditionsAsync in 56346.9137 milliseconds.
But it should be fully 'async'? Because it is still blocking Shapeshifter itself, the showing of an item copied (counter) and also it is locking the clipboard.
And if you would copy something twice the size of this it will take 2 minutes, and in that time you cannot access the clipboard in any way.