Libation icon indicating copy to clipboard operation
Libation copied to clipboard

Mac beta

Open rmcrackan opened this issue 2 years ago • 82 comments

The original Libation is Windows only. We recently did a massive rewrite of the whole UI to make it cross platform. We have some VMs running linux that we can test on but we have no access to a mac. In theory, I should be able to use this same code with some different publish steps and then it will work on mac also.

I need mac people to tell me if it works for them. I know nothing about using a mac. I wouldn't even know if my output file was correct. Further complicating things, I don't know if the Intel/M1/M2 thing matters.

rmcrackan avatar Jul 28 '22 13:07 rmcrackan

Maybe I can help out testing on a M1 mac.

mkb79 avatar Jul 28 '22 13:07 mkb79

@mkb79 Yes please!

Here you go!

Mbucari avatar Jul 28 '22 13:07 Mbucari

@Mbucari Damn you're fast. You beat me to it again. :) I just started looking at the profile.pubxml files. It looks like all I have to do is change these and build as per the linux-chardonnay dotnet publish steps. Is that what you did?

    <PublishDir>..\bin-Avalonia\publish\osx-x64\</PublishDir>
    <RuntimeIdentifier>osx-x64</RuntimeIdentifier>

rmcrackan avatar Jul 28 '22 14:07 rmcrackan

@rmcrackan Yup, that's all. Then it comes down to actually executing it on mac and getting MP3 conversion to work. See the notes in my release.

Mbucari avatar Jul 28 '22 14:07 Mbucari

I just realized, this package probably won't work for @mkb79 for 2 reasons.

He said an M1 mac, which is an arm architecture. My VS install only has a publish profile for mac x64. Also, it looks like only .netcore3.1 and .net6 runtimes are available on mac, but AAXClean targets .net 5.

Mbucari avatar Jul 28 '22 14:07 Mbucari

I hope that since M1 is still (relatively) new, that M1/M2 owners are familiar with how to run and/or virtualize Intel macos. Is it easy to upgrade AAXClean to 6?

rmcrackan avatar Jul 28 '22 14:07 rmcrackan

I'll try this later this day. Maybe Rosetta 2 can help out.

mkb79 avatar Jul 28 '22 14:07 mkb79

Is it easy to upgrade AAXClean to 6?

Pretty easy, but:

  • I'm not sure it's necessary. On linux I only installed the .net6 runtime and everything worked fine.
  • I don't want to screw up anyone else who's using AAXClean.

Mbucari avatar Jul 28 '22 15:07 Mbucari

Especially after my manual mis-release last night, I'm working on my releaser app whenever I can find the time today. Does this look right to you?

build   -c Release -o bin\Release\win-classic      LibationWinForms\LibationWinForms.csproj -p:PublishProfile=LibationWinForms\Properties\PublishProfiles\WindowsProfile.pubxml
build   -c Release -o bin\Release\win-classic      LibationCli\LibationCli.csproj           -p:PublishProfile=LibationCli\Properties\PublishProfiles\WindowsProfile.pubxml
build   -c Release -o bin\Release\win-classic      Hangover\Hangover.csproj                 -p:PublishProfile=Hangover\Properties\PublishProfiles\WindowsProfile.pubxml

build   -c Release -o bin\Release\win-chardonnay   LibationAvalonia\LibationAvalonia.csproj -p:PublishProfile=LibationAvalonia\Properties\PublishProfiles\WindowsProfile.pubxml
build   -c Release -o bin\Release\win-chardonnay   LibationCli\LibationCli.csproj           -p:PublishProfile=LibationCli\Properties\PublishProfiles\WindowsProfile.pubxml
build   -c Release -o bin\Release\win-chardonnay   Hangover\Hangover.csproj                 -p:PublishProfile=Hangover\Properties\PublishProfiles\WindowsProfile.pubxml

publish -c Release -o bin\Release\linux-chardonnay LibationAvalonia\LibationAvalonia.csproj -p:PublishProfile=LibationAvalonia\Properties\PublishProfiles\LinuxProfile.pubxml
publish -c Release -o bin\Release\linux-chardonnay LibationCli\LibationCli.csproj           -p:PublishProfile=LibationCli\Properties\PublishProfiles\LinuxProfile.pubxml

publish -c Release -o bin\Release\macos-chardonnay LibationAvalonia\LibationAvalonia.csproj -p:PublishProfile=LibationAvalonia\Properties\PublishProfiles\MacOSProfile.pubxml
publish -c Release -o bin\Release\macos-chardonnay LibationCli\LibationCli.csproj           -p:PublishProfile=LibationCli\Properties\PublishProfiles\MacOSProfile.pubxml

rmcrackan avatar Jul 28 '22 17:07 rmcrackan

Looks good to me!

Mbucari avatar Jul 28 '22 17:07 Mbucari

New mac version available here - v8.3.1

rmcrackan avatar Jul 28 '22 17:07 rmcrackan

I've got some Intel Macs I can test with.

  1. The 8.3.1 Mac zipfile appears to contain the Linux binaries instead of MacOS
$ file Libation
Libation: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b36f4fb458fe7cb88aa0fbcac547a573ead1362e, for GNU/Linux 2.6.32, stripped

$ file LibationCli
LibationCli: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b36f4fb458fe7cb88aa0fbcac547a573ead1362e, for GNU/Linux 2.6.32, stripped

For comparison, the older 8.3.0 zip contains a Mach-O executable like I'd expect:

$ file Libation
Libation: Mach-O 64-bit executable x86_64
  1. When running the 8.3.0 Libation executable, I got the expected Mac security warnings I needed to allow due to it being an unsigned binary. That's usually a one-time thing, so not the end of the world if you don't want to go down the road of figuring out how to get a developer signing key registered with Apple and figure out how to sign your builds with it. The surprising thing was I also ran into this warning / need to allow for every dll as it tried to load them.

  2. After working through allowing each of those in sequence, it's now bombing with the following error:

$ ./Libation
Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'Avalonia.DesktopRuntime, Version=0.10.17.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b'. An attempt was made to load a program with an incorrect format.

File name: 'Avalonia.DesktopRuntime, Version=0.10.17.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b'
   at LibationAvalonia.Program.Main()
   at LibationAvalonia.Program.<Main>()
[1]    69724 abort      ./Libation

derekgottlieb avatar Jul 28 '22 21:07 derekgottlieb

The 8.3.1 Mac zipfile appears to contain the Linux binaries instead of MacOS

This is confusing. I ran the above dotnet commands and the macos profiles are targeting osx-x64 . @Mbucari - how did you build yours?

rmcrackan avatar Jul 29 '22 01:07 rmcrackan

That's how I built it. IDK man.

Mbucari avatar Jul 29 '22 02:07 Mbucari

@mkb79 Yes please!

Here you go!

I've got these error message:

Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'Avalonia.DesktopRuntime, Version=0.10.17.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b'. An attempt was made to load a program with an incorrect format.

File name: 'Avalonia.DesktopRuntime, Version=0.10.17.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b'
   at LibationAvalonia.Program.Main()
   at LibationAvalonia.Program.<Main>()
zsh: abort      ./Libation

mkb79 avatar Jul 29 '22 11:07 mkb79

@rmcrackan The problem appears to be caused by Visual Studio. Those dotnet commands are fine, but visual studio isn't properly cleaning/restoring between builds on different platforms. Even running dotnet clean -c Release before each build/publish command doesn't solve the problem. I'm sure there's a proper way to do this, but I haven't found it yet. The only way I've found to make SURE that these packages build properly on each OS is to delete all obj\ and bin\ directories for all projects before running publish on each different OS.

VirtualBox_Mac_30_07_2022_14_44_07

Also, I painted myself into a corner with the Avalonia code. Over Here I talked about how I made ShowDialog synchronous and added other synchronous methods for working with Avalonia's async-only forms. Well it turns out that does not work on macOS. So I'll have to go through the code and figure out a way to only call ShowDialog asynchronously. That means converting all static MessageBox.Show() methods to async, among other changes.

VirtualBox_Mac_30_07_2022_14_35_57

Mbucari avatar Jul 30 '22 20:07 Mbucari

@rmcrackan OK, I solved that one. Now we have a new one. This one's all you!

Locking/unlocking file regions is not supported on this platform. Use FileShare on the entire file instead.

   at System.IO.Strategies.FileStreamHelpers.Lock(SafeFileHandle handle, Boolean canWrite, Int64 position, Int64 length)
   at System.IO.Strategies.OSFileStreamStrategy.Lock(Int64 position, Int64 length)
   at System.IO.Strategies.BufferedFileStreamStrategy.Lock(Int64 position, Int64 length)
   at System.IO.FileStream.Lock(Int64 position, Int64 length)
   at Lucene.Net.Store.NativeFSLock.Obtain()
   at Lucene.Net.Store.Lock.Obtain(Int64 lockWaitTimeout)
   at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean create, IndexDeletionPolicy deletionPolicy, Int32 maxFieldLength, IndexingChain indexingChain, IndexCommit commit)
   at Lucene.Net.Index.IndexWriter..ctor(Directory d, Analyzer a, Boolean create, MaxFieldLength mfl)
   at LibationSearchEngine.SearchEngine.CreateNewIndex(IEnumerable`1 library, Boolean overwrite) in D:\OneDrive\Projects\Libation\Source\LibationSearchEngine\SearchEngine.cs:line 192
   at ApplicationServices.SearchEngineCommands.<>c.<FullReIndex>b__7_0(SearchEngine e) in D:\OneDrive\Projects\Libation\Source\ApplicationServices\SearchEngineCommands.cs:line 54
   at ApplicationServices.SearchEngineCommands.update(Action`1 action) in D:\OneDrive\Projects\Libation\Source\ApplicationServices\SearchEngineCommands.cs:line 89
   at ApplicationServices.SearchEngineCommands.performSafeCommand(Action`1 action) in D:\OneDrive\Projects\Libation\Source\ApplicationServices\SearchEngineCommands.cs:line 69
   at ApplicationServices.SearchEngineCommands.FullReIndex() in D:\OneDrive\Projects\Libation\Source\ApplicationServices\SearchEngineCommands.cs:line 53
   at AppScaffolding.LibationScaffolding.<>c.<wireUpSystemEvents>b__24_0(Object _, EventArgs __) in D:\OneDrive\Projects\Libation\Source\AppScaffolding\LibationScaffolding.cs:line 334
   at ApplicationServices.LibraryCommands.finalizeLibrarySizeChange() in D:\OneDrive\Projects\Libation\Source\ApplicationServices\LibraryCommands.cs:line 358
   at ApplicationServices.LibraryCommands.<>c.<importIntoDbAsync>b__18_0() in D:\OneDrive\Projects\Libation\Source\ApplicationServices\LibraryCommands.cs:line 232
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at ApplicationServices.LibraryCommands.importIntoDbAsync(List`1 importItems) in D:\OneDrive\Projects\Libation\Source\ApplicationServices\LibraryCommands.cs:line 232
   at ApplicationServices.LibraryCommands.ImportAccountAsync(Func`2 apiExtendedfunc, Account[] accounts) in D:\OneDrive\Projects\Libation\Source\ApplicationServices\LibraryCommands.cs:line 147
   at LibationAvalonia.Views.MainWindow.scanLibrariesAsync(Account[] accounts) in D:\OneDrive\Projects\Libation\Source\LibationAvalonia\Views\MainWindow\MainWindow.ScanManual.axaml.cs:line 65

Downloading works, but that Lucene error makes Libation pretty much unusable on mac. It crashes after each book is downloaded, presumably because Lucene is trying to re-index and throwing that error. VirtualBox_Mac_30_07_2022_18_09_03

Mbucari avatar Jul 30 '22 21:07 Mbucari

Please see if v8.3.2 acts any better.

rmcrackan avatar Jul 31 '22 13:07 rmcrackan

Please see if v8.3.2 acts any better.

It no longer crashes after updating, but search still doesn't work. You need to change the file lock.

https://github.com/rmcrackan/LuceneNet303r2/blob/74c7175111fab23b550845b2b7485b0cf64950a7/LuceneNet303r2/Store/NativeFSLockFactory.cs#L268-L272

Mbucari avatar Jul 31 '22 14:07 Mbucari

Good call. For now I'm just going to hide those from osx and we'll see how that goes. If need be, I'll replace it with the actual osx recommendation.

rmcrackan avatar Jul 31 '22 18:07 rmcrackan

v8.3.3 hides this lock from Mac. Let's see if we can get further this time.

rmcrackan avatar Jul 31 '22 18:07 rmcrackan

Everything but mp3 seems to work on mac!

But we really do need to do something about the installation / signing. It's not OK to expect users to disable their system malware protection to be able to use an app.

Check out: https://docs.avaloniaui.net/docs/distribution-publishing/macos

Mbucari avatar Aug 01 '22 04:08 Mbucari

@mkb79 @derekgottlieb

Please try the v8.3.4 macOS build.

Also, do either of you have any suggestions for better deployment on macOS to make it more user-friendly? Getting an Apple developer ID and making a .app package is probably out of the question. But short of that, what can/should we do?

My current approach is to run

sudo spctl --master-disable

And then launch Libation from the terminal. There's got to be a better way.

Mbucari avatar Aug 01 '22 15:08 Mbucari

Instead of disable GateKeeper you can run for the whole Libation folder:

sudo spctl --add --label "Libation" ./Libation

I could run Libation. But had to chmod +x ./Libation before. I could only add a new user login with external browser. Import from audible-cli raises an exception and default adding does nothing. A lib sync was successful.

mkb79 avatar Aug 01 '22 19:08 mkb79

sudo spctl --add --label "Libation" ./Libation

Thanks!

But had to chmod +x ./Libation before.

That is a problem that I think can only be solved by packaging the bins in a .tar file with execution permissions already set. I'll work with @rmcrackan on that.

Import from audible-cli raises an exception

Can you please share exception details? Maybe post your log file? I was able to use the Import function, so I suspect the problem is that I didn't correctly match/understand your account file's json structure.

default adding does nothing.

I don't understand what you mean. Can you please explain?

Mbucari avatar Aug 01 '22 20:08 Mbucari

I don't understand what you mean. Can you please explain?

The default way to add an account does not work for me. I filled out my password as Libation asked for it. But after 1 minute of waiting nothing happens. So I logged in using an external url.

mkb79 avatar Aug 02 '22 04:08 mkb79

@mkb79 I understand.

Can you please post your libation log file? It might help illuminate all of the problems you've been experiencing.

Mbucari avatar Aug 02 '22 04:08 Mbucari

@Mbucari pressing the Open Log Folder does not work. Where I can find the logs?

mkb79 avatar Aug 02 '22 04:08 mkb79

Oh gosh, that's a good question. In Linux it inside $HOME/Libation

Is that true on Mac as well?

Mbucari avatar Aug 02 '22 05:08 Mbucari

I'm at work now and my Mac is at home. Will try it later.

mkb79 avatar Aug 02 '22 05:08 mkb79