Flatpak does not open Open/Save requesters

Bug #1956195 reported by Chris Young
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pinta
Fix Released
Undecided
Unassigned

Bug Description

Pinta 2.0 is installed from Flatpak on Raspberry Pi OS 64-bit.

Clicking Open results in the following unhandled exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> GLib.GException: Invalid byte sequence in conversion input
   at GLib.Marshaller.StringToFilenamePtr(String str)
   at Gtk.FileChooserAdapter.SetCurrentFolder(String filename)
   at Pinta.Actions.OpenDocumentAction.Activated(Object sender, EventArgs e)
   at Pinta.Core.Command.<.ctor>b__33_0(Object o, ActivatedArgs args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)

Clicking Save results in the following unhandled exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> GLib.GException: Invalid byte sequence in conversion input
   at GLib.Marshaller.StringToFilenamePtr(String str)
   at Gtk.FileChooserAdapter.SetCurrentFolder(String filename)
   at Pinta.Actions.SaveDocumentImplmentationAction.SaveFileAs(Document document)
   at Pinta.Actions.SaveDocumentImplmentationAction.Activated(Object sender, DocumentCancelEventArgs e)
   at Pinta.Core.FileActions.RaiseSaveDocument(Document document, Boolean saveAs)
   at Pinta.Core.Document.Save(Boolean saveAs)
   at Pinta.Actions.SaveDocumentAction.Activated(Object sender, EventArgs e)
   at Pinta.Core.Command.<.ctor>b__33_0(Object o, ActivatedArgs args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)

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

Interesting, I haven't seen this error before. It looks like it's probably failing around https://github.com/GtkSharp/GtkSharp/blob/develop/Source/Libs/GLibSharp/Marshaller.cs#L130 in the GtkSharp bindings.

Are there any special characters in the file / folder paths?
If not, I'd guess there's some sort of issue either on the dotnet or GTK side of things for arm64

Changed in pinta:
milestone: none → 2.1
Revision history for this message
Chris Young (chris-0zxv) wrote :

I'm not sure what path it is trying to use. Another Flatpak app gives me paths that look like this: /run/user/1001/doc/4c9c5fa0/

If I load a file from disk and then do a Save As (so, in theory I know it's using a valid path) I still get an unhandled exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> GLib.GException: Invalid byte sequence in conversion input
   at GLib.Marshaller.StringToFilenamePtr(String str)
   at Gtk.FileChooserAdapter.SetCurrentFolder(String filename)
   at Pinta.Actions.SaveDocumentImplmentationAction.SaveFileAs(Document document)
   at Pinta.Actions.SaveDocumentImplmentationAction.Activated(Object sender, DocumentCancelEventArgs e)
   at Pinta.Core.FileActions.RaiseSaveDocument(Document document, Boolean saveAs)
   at Pinta.Core.Document.Save(Boolean saveAs)
   at Pinta.Actions.SaveDocumentAsAction.Activated(Object sender, EventArgs e)
   at Pinta.Core.Command.<.ctor>b__33_0(Object o, ActivatedArgs args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)

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

I think it's probably trying to set the file chooser to the last used directory, which you could inspect in ~/.config/Pinta.settings.xml (the 'last-dialog-directory' setting)

Revision history for this message
Chris Young (chris-0zxv) wrote :

After some Googling, I discovered where Flatpak thinks the home dir is, so the path to that file is actually ~/.var/app/com.github.PintaProject.Pinta/config/Pinta/config.xml

I tried removing that line, and modifying it to be ~ and /, but the same exception occurs.

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

Thanks, it sounds like the file path is probably something fairly reasonable.

If you launch pinta from the command line, are there any other warnings etc in the output?

Revision history for this message
Chris Young (chris-0zxv) wrote :

Console output: Pinta does appear to have the xdg-run/gvfsd privileges already.

(Pinta:2): GVFS-WARNING **: 14:06:58.983: The peer-to-peer connection failed: Error when getting information for file “/run/user/1001/gvfsd”: No such file or directory. Falling back to the session bus. Your application is probably missing --filesystem=xdg-run/gvfsd privileges.

(Pinta:2): GVFS-WARNING **: 14:06:58.998: The peer-to-peer connection failed: Error when getting information for file “/run/user/1001/gvfsd”: No such file or directory. Falling back to the session bus. Your application is probably missing --filesystem=xdg-run/gvfsd privileges.
Marshaling activate signal
Pinta: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> GLib.GException: Invalid byte sequence in conversion input
   at GLib.Marshaller.StringToFilenamePtr(String str)
   at Gtk.FileChooserAdapter.SetCurrentFolder(String filename)
   at Pinta.Actions.OpenDocumentAction.Activated(Object sender, EventArgs e)
   at Pinta.Core.Command.<.ctor>b__33_0(Object o, ActivatedArgs args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)

(Pinta:2): GVFS-WARNING **: 14:07:00.480: The peer-to-peer connection failed: Error when getting information for file “/run/user/1001/gvfsd”: No such file or directory. Falling back to the session bus. Your application is probably missing --filesystem=xdg-run/gvfsd privileges.

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

I think I've seen those warnings on x86 systems, so it's (probably) not related. The next step would probably be trying a non-flatpak build of Pinta, which can be built from the Github source easily if you're able to install dotnet and gtk on your system?

Revision history for this message
Chris Young (chris-0zxv) wrote :

Same exception when built myself:

dotnet run --project Pinta

(Pinta:30379): dbind-WARNING **: 19:47:28.012: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
Marshaling activate signal
Pinta: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> GLib.GException: Invalid byte sequence in conversion input
   at GLib.Marshaller.StringToFilenamePtr(String str)
   at Gtk.FileChooserAdapter.SetCurrentFolder(String filename)
   at Gtk.FileChooserNative.SetCurrentFolder(String filename)
   at Pinta.Actions.OpenDocumentAction.Activated(Object sender, EventArgs e) in /media/nas/git-repos/Pinta/Pinta/Actions/File/OpenDocumentAction.cs:line 76
   at Pinta.Core.Command.<.ctor>b__33_0(Object o, ActivatedArgs args) in /media/nas/git-repos/Pinta/Pinta.Core/Actions/Command.cs:line 60
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)

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

Thanks, sounds like it isn't anything flatpak-related. Searching around, I also found https://github.com/MonoGame/MonoGame/issues/7509 which looks similar (interestingly, also on arm64)

Reading the docs for g_filename_from_utf8() mentions that it relies on the current locale - what's the output from the `locale` command for your system?

Revision history for this message
Chris Young (chris-0zxv) wrote :

$ locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

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

Thanks, that looks reasonable to me..

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

Would you be able to try this again from the latest Github version? There have been a bunch of changes in that area so it probably won't be going through GLib.Marshaller.StringToFilenamePtr any more, although it might still fail elsewhere..

Revision history for this message
Chris Young (chris-0zxv) wrote :

I tested the version from GitHub and it is now working as expected!

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

Great, thanks for confirming!
Bug 1958763 was where the file dialog changes were from

Changed in pinta:
status: New → Fix Committed
grofaty (grofaty)
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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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