Can't open small PNG files

Bug #1164222 reported by Teresa e Junior
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pinta
Fix Released
High
Cameron White

Bug Description

Hello, Pinta devs!

When trying to open any 16x16 png file, I'm greeted with a window saying:
Object reference not set to an instance of an object
Could not open file: /home/user/filename.png

Then the file is not opened. When closing Pinta, two new windows appear:
Unhandled exception:
Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: Tried to WorkspaceManager.SetActiveDocument. Could not find document.
  at Pinta.Core.WorkspaceManager.SetActiveDocument (Pinta.Core.Document document) [0x00000] in <filename unknown>:0
  at Pinta.Core.WorkspaceManager.SetActiveDocument (Int32 index) [0x00000] in <filename unknown>:0
  at Pinta.Core.WorkspaceManager.CloseDocument (Pinta.Core.Document document) [0x00000] in <filename unknown>:0
  at Pinta.Core.WorkspaceManager.CloseActiveDocument () [0x00000] in <filename unknown>:0
  at Pinta.Actions.CloseDocumentAction.Activated (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0

Unhandled exception:
Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Pinta.Core.WindowActions.RemoveDocument (Pinta.Core.Document doc) [0x00000] in <filename unknown>:0
  at Pinta.ActionHandlers.Workspace_DocumentClosed (System.Object sender, Pinta.Core.DocumentEventArgs e) [0x00000] in <filename unknown>:0
  at (wrapper delegate-invoke) <Module>:invoke_void__this___object_DocumentEventArgs (object,Pinta.Core.DocumentEventArgs)
  at Pinta.Core.WorkspaceManager.OnDocumentClosed (Pinta.Core.DocumentEventArgs e) [0x00000] in <filename unknown>:0
  at Pinta.Core.WorkspaceManager.CloseDocument (Pinta.Core.Document document) [0x00000] in <filename unknown>:0
  at Pinta.Core.WorkspaceManager.CloseActiveDocument () [0x00000] in <filename unknown>:0
  at Pinta.Actions.CloseDocumentAction.Activated (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0

Reproducible on 1.4-1 and 1.5+r782 on Debian Wheezy.

Thanks for your attention!

Revision history for this message
Cameron White (cameronwhite91) wrote :

Do you have any sample images that you could attach? I tried creating a 16x16 png image in Pinta and then re-opened it in Pinta, and everything worked fine (I'm using Pinta 1.5 on Ubuntu 12.10)

Revision history for this message
Teresa e Junior (teresaejunior) wrote :

Hi, Cameron! Thanks for your answer!

Unfortunately I can reproduce it on any 16x16 icon file. I also resized a big PNG image to 16 pixels, and then Pinta refused to open it.

I have attached an icon that I used on my last test.

Thank you!

Revision history for this message
Teresa e Junior (teresaejunior) wrote :

I just tested and 1.3-2 from Debian Wheezy doesn't have this problem. 1.4-1 is the Debian package from experimental and 1.5+r782 I compiled from the deb-src of this PPA.

Revision history for this message
grofaty (grofaty) wrote :

I opened attached file in Pinta latest development in Ubuntu 12.04 and pinta-1.5-preview-20130309 on Windows XP. Can't replicate the problem. In my case file opens without a problem. Maybe system specific or some desktop manager specific...

Revision history for this message
David Couzelis (drcouzelis) wrote :

I too am experiencing this bug. I tracked down the size: If either the width or the height of the image is less that 25 pixels then Pinta will fail to load it. This is true for both PNG and ORA images.

Tested with both Pinta 1.4-1 and the latest git code.

If the stack trace that has already been posted doesn't help you, is there something else I can do to give you more information?

System information: Arch Linux, updated today.

Thank you.

Revision history for this message
Cameron White (cameronwhite91) wrote :

Looks like multiple people are seeing this issue, so I'm marking it as confirmed.

All of the images open fine on my system (Ubuntu 12.10, latest development version of Pinta), so there might be issues with newer versions of GTK# or something like that.

Would it be possible to get a stack trace when the file fails to open? The stack traces in the original comment are only for crashes that appear when trying to close Pinta after attempting to open these files.

Changed in pinta:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Teresa e Junior (teresaejunior) wrote :

Please, how can I get a strace for Pinta, since I have to call mono first?

Revision history for this message
Cameron White (cameronwhite91) wrote :

It should be the same as the other error logs you provided - i.e. when you get the initial error ("Object reference not set to an instance of an object. Could not open file: /home/user/filename.png") does the error dialog also include a stack trace?

Revision history for this message
Teresa e Junior (teresaejunior) wrote :

No, it doesn't...

I have tried:
$ gdb --args /usr/bin/mono /usr/lib/pinta/Pinta.exe
  and
$ gdb /usr/bin/mono
(gdb) run /usr/lib/pinta/Pinta.exe

and both fail with:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".
[New Thread 0xb7c94b70 (LWP 26047)]
[New Thread 0xb7105b70 (LWP 26048)]

Program received signal SIGPWR, Power fail/restart.
[Switching to Thread 0xb7105b70 (LWP 26048)]
0xb7fe1424 in __kernel_vsyscall ()

So now I'm clueless...

Revision history for this message
Teresa e Junior (teresaejunior) wrote :

Now I tried the following, but the three lines are printed only when I close Pinta too:

$ mono --debug /usr/lib/pinta/Pinta.exe
Marshaling activate signal
Marshaling activate signal
Cairo.Context: called from finalization thread, programmer is missing a call to Dispose

Revision history for this message
Teresa e Junior (teresaejunior) wrote :

I'm sorry for so many emails...

I tried following http://www.mono-project.com/Debugging and `mono --trace /usr/lib/pinta/Pinta.exe >trace.log' produced a file of 328MB, then I killed it...

Revision history for this message
Cameron White (cameronwhite91) wrote :

Sorry about that, I forgot that the dialog for errors when opening files was slightly different and didn't give any details. I've fixed that now (https://github.com/PintaProject/Pinta/commit/471662271a276ec91d0063dfe9a29ce9313b2be5), and that change should appear in the development PPA within a day or two.

Revision history for this message
David Couzelis (drcouzelis) wrote :

The stack trace from a build with the source code from today:

http://pastebin.com/hFMt7hrt

Revision history for this message
Cameron White (cameronwhite91) wrote :

Thanks, that's very helpful!

The code where the crash is happening is only used when the Pixel Grid is enabled, so turning that feature off should give you a workaround until a proper fix is implemented.

Revision history for this message
David Couzelis (drcouzelis) wrote :

I can confirm that this workaround works. Disabling the pixel grid, loading any size image, and then enabling the pixel grid works fine.

Thank you for your hard work on this great piece of software! :)

Revision history for this message
grofaty (grofaty) wrote :

I can also replicate on pinta-1.5-preview-20130309 on Windows XP. But it looks like problem only appears first time after Pinta is opened:
1. Start Pinta (if already started then restart Pinta).
2. View | uncheck Pixel Grid.
3. Open button from toolbar and select image from #5.
4. Ctrl+W to close current opened image.
5. View | check Pixel Grid.
6. Open button from toolbar and select image from #5. Image is opened without a problem.
It looks to me that something is wrong at first start-up, maybe some parameter is not correctly saved and loaded from settings file.

Revision history for this message
Cameron White (cameronwhite91) wrote :
Changed in pinta:
assignee: nobody → Cameron White (cameronwhite91)
milestone: none → 1.5
status: Confirmed → Fix Committed
Revision history for this message
Teresa e Junior (teresaejunior) wrote :

Thank you so much, Cameron! It works great now!

Revision history for this message
Patrick Dreier (patrick-dreier) wrote :

Hello!

I have this problem on first open on pinta-1.5-preview-20130615.exe.

With king regards!

Revision history for this message
Patrick Dreier (patrick-dreier) wrote :

Hello!

I have this Problem off PNG file on Windows pinta-1.5-preview-20130615.exe.

With king regards!

Changed in pinta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.