Does Xojo Support File Opening on Linux?

I just purchased Xojo so I could generate a linux executable.

I copied the executable and libs over to a VM running Centos 7.9.

It complained about not being able to find libunwind.so, so I installed that via yum.

The application loaded up and the gui was displayed, but when it came to opening and reading a file it promptly segfaulted!.

I created a new simple App with one button whose action code is detailed below. I ran this on windows and a message box popped up telling me how many lines had been read.

I built this for linux and copied the files over, fired it up, pressed the button, chose a file in the file manager and it segfaulted.

Should this code work on Linux like it does in Windows? I wondering if Xojo Linux support isnā€™t that stable or as comprehensive as the marketing docs claim?

Thanks for your time,
Carl C.

Var File As FolderItem = FolderItem.showOpenFileDialog("")

Var lineIndex() As Integer

Var input As TextInputStream
input = TextInputStream.Open(file)

While Not input.EndOfFile
Var tmpStr As String = input.readLine()
lineIndex.Add(input.BytePosition())
Wend

MessageBox ("Read lines: " + lineIndex.LastIndex.toString + EndOfLine)

input.close()

If I donā€™t use the showOpenFileDialog call, and instead set the file path/name programmatically the code works fine (see below). So, Iā€™m guessing that the FileDialog is returning a null/nil FolderItem, even though Iā€™m opening the same file that I set programmatically.

Interestingly if I add a check for nill on the file variable before I use it, OR if I new the file FolderItem before trying to assign it to the return of showOpenFileDialog it still segFaults. Which would suggest that at least in Centos 7.9 the open file dialog becomes unstable after selecting a file and before returning, so it looks like its fundamentally broken as opposed to something Iā€™m doing.

// Var file As FolderItem = FolderItem.showOpenFileDialog("")

Var file As FolderItem = New FolderItem("/home/user/Projects/Xojo/FileTestA/num.txt", FolderItem.PathModes.Shell)
var lineIndex() As Integer

Var input As TextInputStream
input = TextInputStream.Open(file)

While Not input.EndOfFile
Var tmpStr As String = input.readLine()
lineIndex.Add(input.BytePosition())
Wend

MessageBox ("Read lines: " + lineIndex.LastIndex.toString + EndOfLine)

input.close()

Oh, and if I use the code from the xojo docs on openFileDialog (http://documentation.xojo.com/api/user_interface/desktop/openfiledialog.html which explicitly mentions ā€œTargetLinuxā€ it also SegFaults on Centos 7.9. Guess Iā€™ll need to implement some kind of file chooser myself, or reduce the functionality to users needing to cut ā€˜nā€™ paste their path/file into a TextBox. Kind of disappointing for my first foray into Xojo/Linux ā€¦ but at least it can be worked around.

Have you checked whether the two folderitems are really pointing to the same file? Check their NativePath properties. Itā€™s fairly possible the OpenFileDialog returns another file (e.g. by resolving symbolic links).

If youā€™re sure they are the same file, thatā€™s surprising. I canā€™t see how showing an OpenFileDialog would interfere with reading the file later. Perhaps the dialog retains some kind of preview?

Iā€™d try some more things:
1: try reading as a binary stream instead of a text input stream.
2: try not reading at all. e.g. Show a MessageBox telling the size of the file.
3: try delaying between showing the OpenFileDialog and accessing the file; perhaps a delay would allow the file to be released, should it be retainedā€¦
4: put a breakpoint before opening the file and check if its properties are correct.
5: either build your app or run it paused; in both cases, you get an executable file not yet launched. Open the Terminal and launch your app from there. When the SegFault occurs, the Terminal should tell you more about the problem.

Thanks for the feedback.

Itā€™s definitely the same file, its a text file with numbers from 0 to 100 that tested the code against of windows and then moved to linux, in the same place that I copied the xojo executable to.

I canā€™t check the actual ā€œpointersā€ since the executable crashes before the openFileDialog returns a FolderItem handler, pointer, object (whatever xojo calls it). E.g. if I do

Var file As New FolderItem
file = FolderItem.showOpenFileDialog("")
If file <> Nil Then
MessageBox (ā€œFile openedā€)
Else
MessageBox (ā€œFile was Nilā€)
End If

It crashes with the SegFault right after I select the file in the dialog, and before it gets to the Nil check. Note: Iā€™m not even trying to open the file or do operations on itā€¦ just a simple Nil check as per the xojo documentation for openFileDialog.

Re 1: it dies before I can even open it as a text stream, so Iā€™m guessing the binary stream wont help.
Re 2: Yep, I tried that and it dies after clicking the file in the dialog.
Re 3: Hmmm, I canā€™t expect my users to wait an arbitrary time before interacting with the dialog that just opened for them. But, I tried it and it still dies.
Re 4: It dies before I can even check if the FolderItem is Nil, so nope cant check its properties.

Re 5: Iā€™m actually building on windows and then copying over to linux, I think youā€™re suggesting that I install xojo onto linux and build thereā€¦ Iā€™ll give this a go.

My suspicion is that there is a incompatibility between centos 7.9 and whatever xojo is doing on the backend for linux, but I think trying the linux installation of xojo is a good idea.

Thanks,
Carl C.

Well I think that confirms that there is a problem with Xojo and Centos 7.9 at least where file dialogs are concerned.

I installed the linux version of Xojo. It fired up fine, I created a new project. Added a button with an action handlerā€¦ cut n pasted my code over from windows. Then I went to run it.

Before I could run, I needed to save it. The save dialog window opened, I navigated to my project directory, I created a new folder I clicked saveā€¦ and BAM!!

libocci.so.10.1: cannot open shared object file: No such file or directorySegmentation fault (core dumped)

According the forums one should remove the OraclePlugin ā€¦ so I did that.

Started up Xojo again, created a project, added a buttonā€¦ blah blah.

Went to save the project, and BAMā€¦

Segmentation fault (core dumped).

Sooooooā€¦ Iā€™m guessing the previous error message was actually two errors.

Iā€™m pretty sure there is an issue with Centos 7.9 and the file dialog windows.

Carl C.

So itā€™s safe to say that it crashes ā€œinā€ the file dialog. Please fill a feedback report (use the Feedback button in Xojo) and report this bug, that you could reproduce.

This will still eliminate potential bugs.
And once youā€™ve built right on Linux, use the Terminal to launch your app. Thatā€™s important as youā€™ll probably see more information about the crash in the Terminal window (rather than just the app disappearing).

Please make sure this file is actually installed. Iā€™m guessing your current installation isnā€™t 100% supported yet and you have to install this library. You can check the compatibility page of Xojo.

Iā€™ve filled a support ticket with the issue and a reference to this thread.

Unfortunately, it looks like I canā€™t save the project to get to running my app. So, yep definitely a little flakey on Centos 7.9.

Carl C.

Apparently that requires me to install the ā€œOracle Instant Clientā€ from Oracleā€¦ Iā€™m probably not going to do that. I was really excited with the prospect of developing cross platform apps, especially those that claimed to be self contained. My experience is that most companies donā€™t give you root access to linux and getting the corporate IT department to install things like ā€œOracle Instant Clientā€ on all the workstations is going to dissuade potential users. Something like gnu libunwind may be doable, but when it comes to installing a whole package from oracle just for a simple $20 labor saving app is probably not going to fly. Iā€™ll do some more research, but its not looking as simple as ā€œjust develop the app and share it across different platformsā€, if that linux platform has to be a very customized distribution.

Several Linux distributions are supported, including CentOS. Iā€™m not a Linux expert, so I donā€™t know how much that represents, but you can already take a look there: http://documentation.xojo.com/resources/system_requirements_for_current_version.html

It says:

CentOS 7 or later

So, apparently I should be good to go with Centos 7.9.

Have you customised your CentOS installation in a way that it wouldnā€™t work for Xojo? :man_shrugging:

64Bits ?

The LR have examples and these use TRYā€¦

Read there:

https://documentation.xojo.com/api/files/textinputstream.html

Try/catch blocks wonā€™t help when an app hard crashes. These handle exceptions, but hard crashes donā€™t generate exceptions (the app is just terminated).

Apparently the Xojo Devs have recreated the issue themselves (#65751), so I guess this isnā€™t something peculiar to my relatively clean install on centos 7.9 in a VM.

Thanks for all the suggestions!

1 Like

I worked around this by creating my own open file dialog, which works perfectly on both windows and linux.

LinuxFileChooser

Iā€™m able to double click on folders to navigate up and down the folder hierarchy, and then once a file is selected and the open button clicked, I get back a FolderItem for the file that was selected. So far no SegFaults in sight :grinning: .

Its simple, but effective. Iā€™m a little happier with Xojo ā€¦ it took me a while to get my head around getting an object into and out of a modal window, but other than that it was relatively straight forward and painless. Iā€™m pretty sure I can make it more fancy as and when I need to.

1 Like

While itā€™s true you can make your own ā€œselect fileā€ dialog, itā€™s usually not a great idea. As soon as your original issue with the built-in dialog gets resolved, I suggest you to use it again.

Here are some things an intermediate or advanced user may want:
Control+N or Command+N to create a new folder.
Backspace or Command-Up arrow to move to the parent folder.
Auto-detect when an item is added, removed or renamed in the current list (refresh the list).
Columns showing other data than just the name.
An expected UI.
(etc.).
Some users would be disappointed to not see these things.