Kierof Posted September 30, 2021 Posted September 30, 2021 Hello, everybody. My name is Kierof and I think I have a problem about running Paint.net after I installed the latest update. Look at the picture below. I was about finding the way to making program running again. I found this problem since yesterday when the program notified me about installing the latest version of paint.net. (which is 4.3.1) When I installed it, the program cannot be run and using about 18% of CPU. Is there any advise to help this? I'm very thank you for whoever can solve this problem! Quote
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 Looks like the same issue reported over here: https://forums.getpaint.net/topic/118696-paintnet-43-is-not-responding-for-me-when-i-open-it/ We don't have a solution yet, but could you try the same troubleshooting attempts? (e.g. run with /disablePlugins, and with the parameter to disable hardware acceleration?) Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Kierof Posted September 30, 2021 Author Posted September 30, 2021 I've tried, but still same result. So I hope it'll getting fixed soon! Quote
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 Well I can't fix it until I know what's going on Can you create a performance trace? https://forums.getpaint.net/topic/113249-how-to-submit-a-performance-trace/ Basically, start the trace recording, then start Paint.NET, let it hang, then let it sit for 10 seconds or so, then save the trace. You might need to upload it to a cloud sharing thing because the files can get large. If Paint.NET is sitting there chewing up CPU (you said 18%), this will tell me where in the code it's chewing up CPU, and that will be the smoking gun I need. Feel free to ask any questions to help get this trace stuff working, it's not the simplest thing to get going. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Kierof Posted September 30, 2021 Author Posted September 30, 2021 https://drive.google.com/file/d/1CCfLHJBAVWVojs60am87wAm3_j9-rYJW/view?usp=sharing Here's the performance trace! Hope this will help you! 1 Quote
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 @Kierof, when the program hangs like this, are you opening a specific image, or just starting the app (which gives you the default/blank image) ? If the former (a specific image), can you share that image? Something's goofy with some metadata handling ... Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Kierof Posted September 30, 2021 Author Posted September 30, 2021 I don't know which picture cause the crash of the program, but I remember correctly, I did about many pixel arts of Roblox's texture for uploading. Do you know that picture's file name? I'll search and try to do a solution. Quote
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 How would I know the picture's file name So are you saying that Paint.NET opens fine if you just launch it without opening a specific image? Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 This is what I'm able to see from the performance trace. It seems that the code that handles the DPI / resolution is getting into some kind of infinite loop. The units of measurement for DPI are being retrieved, but they don't exist in the image (which is normal), so the code sets it to the default. Then an event is raised to notify the other parts of the app that the units have changed (which is normal). But then it just starts over again and keeps going in around in circles (not normal). @null54 might you have a clue here? I'll keep looking into this, maybe I haven't had enough caffeine, but I can't yet figure out why this is happening. Thankfully the symbols and stacks are loading in this trace. @Kierof this was very helpful Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
otuncelli Posted September 30, 2021 Posted September 30, 2021 I might have an idea. I checked with ILSpy. PaintDotNet.Document.DpuUnit's getter and setter method seems to end up calling each other recursively. Floating point value equality check seems wrong in DpuX/DpuY setter methods which is called by DpuUnit's setter method. DpuUnit also sets DpuX and DpuY values to 1.0 in its setter. if (DpuUnit == MeasurementUnit.Pixel && value != 1.0) I'd do floating point equality checks with a tolerance value. Also ordering of expressions look important to me. Because second expression is depending on another property's value and this makes the code more prone to bugs. if (Math.Abs(value - 1.0) > 0.1 && DpuUnit == MeasurementUnit.Pixel) Quote
midora Posted September 30, 2021 Posted September 30, 2021 Looks like get_DpuUnit doesn't remember that it just set the default values and instead of returning the values sets them again. Because the subscriber calls get_DpuUnit there will be an infinite loop. Quote
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 Yes, the recursive call is at the heart of this matter which is causing the infinite loop. Although why app keeps spinning around in circles instead of crashing with a stack overflow is unclear to me. This is ooooooolllllllldddddddddd code (ca. 2005) and has always worked fine, despite being an objectively terrible, awful, ugly, and (dare I say) dumb way of doing it. But, it should work. get_DpuUnit shouldn't need to remember that it just set the value via set_DpuUnit. It should be able to get the value when it calls into Metadata.GetExifPropertyItems(). My current investigation is looking into why Metadata either can't find the EXIF metadata, or isn't storing it correctly, or isn't caching it correctly. If I can catch this in the act then it should be very easy to solve. If there's an image that causes this to happen, then all I need is the image. If this happens even when launching Paint.NET without an image to open (e.g. just click on the app icon in Start, taskbar, desktop, anywhere) then it must be dependent on some other factor. The diagnostic info that @WinnythailandFX posted over at https://forums.getpaint.net/topic/118696-paintnet-43-is-not-responding-for-me-when-i-open-it/ shows en-US (English U.S.) as the culture/locale, so I'm not sure it's that. All of the string handling in Metadata is using the Invariant culture with case-insensitivity, so it shouldn't be dependent on a user or system setting. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 Another major question is why did this work fine in 4.2.16, but is no longer working in 4.3? The Metadata class didn't change for 4.3. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
midora Posted September 30, 2021 Posted September 30, 2021 32 minutes ago, Rick Brewster said: My current investigation is looking into why Metadata either can't find the EXIF metadata, or isn't storing it correctly, or isn't caching it correctly. Worst case paint.net can not rely on the Metadata 'remembering' (or it just takes some time). Always a mess if issues can not be reproduced locally. Quote
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 Okay I figured it out. The key ended up noticing this one line over in @WinnythailandFX's diagnostics info: Build Date 4 สิงหาคม 2563 (August 4, 2021) Using Google Translate to translate "สิงหาคม" reveals that it's Thai (th-TH). If I set CultureInfo.CurrentCulture to th-TH at app startup, then the hang reproduces. The code causing the problem is deep in the bowels of some old crusty code over in SystemLayer's PropertyItem2, which is used for serializing/deserializing GDI+ PropertyItem instances: private static string GetProperty(string blob, string propertyName) { string findMe = propertyName + "=\""; int startIndex = blob.IndexOf(findMe) + findMe.Length; int endIndex = blob.IndexOf("\"", startIndex); string propertyValue = blob.Substring(startIndex, endIndex - startIndex); return propertyValue; } If blob equals e.g. "<exif id=\"296\" len=\"2\" type=\"3\" value=\"AgA=\" />", the startIndex and endIndex values are 10 and 10, respectively. These are definitely not the right values, and we get an empty string, and the calling code can't parse an empty string to an integer. An exception is raised, and the error handling code doesn't really do the right thing either. Adding StringComparison.InvariantCultureIgnoreCase to the IndexOf calls and voila, it works. 1 1 2 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Rick Brewster Posted September 30, 2021 Posted September 30, 2021 @Kierof and @WinnythailandFX, try installing this build to verify that my fix is correct: Installer (x64): https://www.getpaint.net/files/zip/test/paint.net.4.302.7943.32044.install.x64.zip Portable(x64): https://www.getpaint.net/files/zip/test/paint.net.4.302.7943.32044.portable.x64.zip In the meantime, I'll start pushing a new 4.3.2 update ASAP. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Kierof Posted October 1, 2021 Author Posted October 1, 2021 It worked now! Thank you for fixing the bug! I'm very appreciate a lot! 😆 1 Quote
midora Posted October 1, 2021 Posted October 1, 2021 For years I'm fighting with c# methods which do not use InvariantCulture as default. And as always Switzerland is special because it uses a comma as decimal separator in all numbers but not in currencies (there a dot is used)... Quote
Solution Rick Brewster Posted October 4, 2021 Solution Posted October 4, 2021 4.3.2 is out with the fix: Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.