KinsonDigital / Velaptor

2D game development framework
https://docs.velaptor.io
MIT License
70 stars 16 forks source link

🐛 Compile on Linux fails with error #692

Open Hendrin-Mckay opened 1 year ago

Hendrin-Mckay commented 1 year ago

Complete The Items Below

Current Behavior

Using Rider on EndeavourOS (A variant of Arch Linux) to compile a very simple example with Velaptor causes an error during compilation.

Expected Behavior

To compile properly and pop up a Window as per the exact same process on Windows 11 and Rider using the same version of .net.

Steps To Reproduce

  1. Create a new console C# project with Rider
  2. Using NuGet, add kinsondigital.velaptor/1.0.0-preview.23 to project.
  3. Create a simple Game.cs with:
    
    using Velaptor.UI;

namespace GameApp;

public class Game : Window {

}

4.  Create a simple Program.cs with:

var game = new GameApp.Game(); game.Show();


5.  Compile Program.cs causes the following compile time error:

/home/hendrin/RiderProjects/GameApp/GameApp/bin/Debug/net7.0/GameApp
Unhandled exception. SimpleInjector.ActivationException: The configuration is invalid. Creating the instance for type IItemCache<string, ITexture> failed. Field not found: 'FreeTypeSharp.Native.FT.FT_Init_FreeType'. Verification was triggered because Container.Options.EnableAutoVerification was enabled. To prevent the container from being verified on first resolve, set Container.Options.EnableAutoVerification to false.
 ---> System.InvalidOperationException: The configuration is invalid. Creating the instance for type IItemCache<string, ITexture> failed. Field not found: 'FreeTypeSharp.Native.FT.FT_Init_FreeType'.
 ---> SimpleInjector.ActivationException: Field not found: 'FreeTypeSharp.Native.FT.FT_Init_FreeType'.
 ---> System.MissingFieldException: Field not found: 'FreeTypeSharp.Native.FT.FT_Init_FreeType'.
   at Velaptor.NativeInterop.FreeType.FreeTypeInvoker.FT_Init_FreeType()
   at Velaptor.Content.Fonts.Services.FontService..ctor(IFreeTypeInvoker freeTypeInvoker, ISystemMonitorService sysMonitorService, IPlatform platform)
   at lambda_method36(Closure)
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.Execute(Func`1 instanceCreator)
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
   at SimpleInjector.InstanceProducer.BuildExpressionInternal()
   at SimpleInjector.Internals.LazyEx`1.InitializeAndReturn()
   at SimpleInjector.InstanceProducer.BuildExpression()
   --- End of inner exception stack trace ---
   at SimpleInjector.InstanceProducer.BuildExpression()
   at SimpleInjector.Registration.BuildConstructorParameters(ConstructorInfo constructor)
   at SimpleInjector.Registration.BuildNewExpression()
   at SimpleInjector.Registration.BuildTransientExpression()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
   at SimpleInjector.InstanceProducer.BuildExpressionInternal()
   at SimpleInjector.Internals.LazyEx`1.InitializeAndReturn()
   at SimpleInjector.InstanceProducer.BuildExpression()
   at SimpleInjector.Registration.BuildConstructorParameters(ConstructorInfo constructor)
   at SimpleInjector.Registration.BuildNewExpression()
   at SimpleInjector.Registration.BuildTransientExpression()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
   at SimpleInjector.InstanceProducer.BuildExpressionInternal()
   at SimpleInjector.Internals.LazyEx`1.InitializeAndReturn()
   at SimpleInjector.InstanceProducer.BuildExpression()
   at SimpleInjector.InstanceProducer.VerifyExpressionBuilding()
   --- End of inner exception stack trace ---
   at SimpleInjector.InstanceProducer.VerifyExpressionBuilding()
   at SimpleInjector.Container.VerifyThatAllExpressionsCanBeBuilt(InstanceProducer[] producersToVerify)
   at SimpleInjector.Container.VerifyThatAllExpressionsCanBeBuilt()
   at SimpleInjector.Container.VerifyInternal(Boolean suppressLifestyleMismatchVerification)
   at SimpleInjector.Container.Verify(VerificationOption option)
   at SimpleInjector.Container.Verify()
   at SimpleInjector.Container.NotifyAndLock()
   --- End of inner exception stack trace ---
   at SimpleInjector.Container.NotifyAndLock()
   at SimpleInjector.Container.GetInstance[TService]()
   at Velaptor.Factories.WindowFactory.CreateWindow()
   at Velaptor.UI.Window..ctor()
   at GameApp.Game..ctor()
   at Program.<Main>$(String[] args) in /home/hendrin/RiderProjects/GameApp/GameApp/Program.cs:line 2

Process finished with exit code 134.

### Operating System(s)

Linux

### OS Version

Endeavouros_Cassini_Nova-03-2023_R3
Kernel 6.4.10-arch1-1

### Anything Else

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

<!--closed-by-pr:983-->
stale[bot] commented 2 months ago

This issue has been automatically marked as stale due to the lack of activity for 60 days. The issue will be closed after 7 days if no further activity occurs. Thank you for your contributions.

CalvinWilkinson commented 1 month ago

@Hendrin-Mckay Thank you for bringing this issue to my attention.

I apologize for posting this so late. The notification system built into GitHub is horrible, and I have had issues with missing stuff before because the notifications don't come through as they should.

I will be honest, though: I have kept the direction of Velaptor as primarily cross-platform, but I have yet to do heavy testing and know there will be issues. I have been planning an initiative to dig my heels in and spend a bunch of time getting Velaptor working on Linux with no problems.

I have contributors who come through, but only a few, and 99% of these projects are maintained solely by me. I also have a client, so it isn't easy to get the things I want done.

Again, thanks for filing this issue! Greatly appreciate that! If you are interested in contributing anything, even noncode-related, let me know!

CalvinWilkinson commented 1 month ago

@Hendrin-Mckay Also, can you let me know if you have tried this with the latest version of Velaptor?

Hendrin-Mckay commented 1 month ago

I understand and no worries.

I just tried with the latest version of Velaptor (Preview 36) and got the following:

Unhandled exception. SimpleInjector.ActivationException: The configuration is invalid. Creating the instance for type IFontFactory failed. The registered delegate for type IFontStatsService threw an exception. Currently loading system fonts is only supported on Windows. Verification was triggered because Container.Options.EnableAutoVerification was enabled. To prevent the container from being verified on first resolve, set Container.Options.EnableAutoVerification to false.
 ---> System.InvalidOperationException: The configuration is invalid. Creating the instance for type IFontFactory failed. The registered delegate for type IFontStatsService threw an exception. Currently loading system fonts is only supported on Windows.
 ---> SimpleInjector.ActivationException: The registered delegate for type IFontStatsService threw an exception. Currently loading system fonts is only supported on Windows.
 ---> System.NotSupportedException: Currently loading system fonts is only supported on Windows.
   at Velaptor.Factories.PathResolverFactory.CreateSystemFontPathResolver()
   at Velaptor.Factories.PathResolverFactory.CreateFontPathResolver()
   at Velaptor.IoC.<>c.<SetupServices>b__13_0()
   at lambda_method70(Closure)
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.Execute(Func`1 instanceCreator)
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
   at SimpleInjector.InstanceProducer.BuildExpressionInternal()
   at SimpleInjector.Internals.LazyEx`1.InitializeAndReturn()
   at SimpleInjector.InstanceProducer.BuildExpression()
   --- End of inner exception stack trace ---
   at SimpleInjector.InstanceProducer.BuildExpression()
   at SimpleInjector.Registration.BuildConstructorParameters(ConstructorInfo constructor)
   at SimpleInjector.Registration.BuildNewExpression()
   at SimpleInjector.Registration.BuildTransientExpression()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
   at SimpleInjector.InstanceProducer.BuildExpressionInternal()
   at SimpleInjector.Internals.LazyEx`1.InitializeAndReturn()
   at SimpleInjector.InstanceProducer.BuildExpression()
   at SimpleInjector.InstanceProducer.VerifyExpressionBuilding()
   --- End of inner exception stack trace ---
   at SimpleInjector.InstanceProducer.VerifyExpressionBuilding()
   at SimpleInjector.Container.VerifyThatAllExpressionsCanBeBuilt(InstanceProducer[] producersToVerify)
   at SimpleInjector.Container.VerifyThatAllExpressionsCanBeBuilt()
   at SimpleInjector.Container.VerifyInternal(Boolean suppressLifestyleMismatchVerification)
   at SimpleInjector.Container.Verify(VerificationOption option)
   at SimpleInjector.Container.Verify()
   at SimpleInjector.Container.NotifyAndLock()
   --- End of inner exception stack trace ---
   at SimpleInjector.Container.NotifyAndLock()
   at SimpleInjector.Container.GetInstance[TService]()
   at Velaptor.Factories.WindowFactory.CreateWindow()
   at Velaptor.UI.Window..ctor()
   at HelloVelaptor.Game..ctor()
   at Program.<Main>$(String[] args) in /home/hendrinm/RiderProjects/TestApp/TestApp/Program.cs:line 3

Process finished with exit code 134.

It still seems to be a font issue, although a different error this time, in that loading system fonts is only supported on Windows, hence why it would throw an exception on Linux. Systems fonts are usually stored in /usr/share/fonts on Linux.

I'm not sure I got a good enough grasp of C# yet to be able to contribute but I will definitely let you know.

Operating System(s)

Linux

OS Version

Endeavouros Gemini Kernal 6.9.6-arch1-1 Gnome/Wayland

Hendrin-Mckay commented 1 month ago

I will see if I can make heads of tails of the code and perhaps submit a PR if I can. I did comment out the exceptions for Windows only and if I copied the TTF fonts to a /Content/Fonts directory where it builds, it all runs, so this was the only blocker for things running on Linux as I got a few of the examples working fine as well as the font rendering example.

CalvinWilkinson commented 1 month ago

I will see if I can make heads of tails of the code and perhaps submit a PR if I can. I did comment out the exceptions for Windows only and if I copied the TTF fonts to a /Content/Fonts directory where it builds, it all runs, so this was the only blocker for things running on Linux as I got a few of the examples working fine as well as the font rendering example.

That is great news!! I am super glad that it ran that well. That means less work for me. 😊

It would be awesome if you could help out. No pressure, though. I understand how busy we can all be. Let me know if you need anything at all. I think I saw your name on the Discord server, so you can also reach me there.

Hendrin-Mckay commented 1 month ago

Made a draft pull request. Still learning Git and Github so if I did something in correct please let me know: https://github.com/KinsonDigital/Velaptor/pull/982

Hendrin-Mckay commented 1 month ago

Screenshot from 2024-06-29 20-32-42 Space Shooter Example Running on EndeavourOS Linux. Still trying to resolve the issue where the window has to be resized before it renders.

CalvinWilkinson commented 1 month ago

Made a draft pull request. Still learning Git and Github so if I did something in correct please let me know: #982

Not a problem at all. I added a comment to that pull request with some more info. I understand that you are new and that is completely fine. 😊

If you have any questions about git and github, practices and how to contribute, let me know and let's talk about it!! 🚀

Hendrin-Mckay commented 1 month ago

My apologies in getting back to this. Was dealing with COVID. Attempting to do a new draft pull request following the Contribution Guidelines.

CalvinWilkinson commented 1 month ago

My apologies in getting back to this. Was dealing with COVID. Attempting to do a new draft pull request following the Contribution Guidelines.

No apologies are necessary! 😀

Thanks for responding though. Greatly appreciated.

CalvinWilkinson commented 3 weeks ago

@Hendrin-Mckay

Quick Update

I am currently working through some content-loading-related changes. These changes have been in the backlog for a while and involve improvements and more cross-platform compatibility. Because of this and what I have discovered so far, I would please ask that you do not waste your time on this issue.

There will be too many changes, conflicts, and a direction that I might have to change, making your contributions on this issue pointless.

I am going to assign this issue to myself to tackle later, as it concerns some other changes that I have to deal with.

I apologize for any time you might have wasted on this. If you are interested in possibly tackling something else or something else, please let me know!

Hendrin-Mckay commented 2 weeks ago

No worries and no need to apologize.

Will do!

CalvinWilkinson commented 2 weeks ago

No worries and no need to apologize.

Will do!

Thanks @Hendrin-Mckay !!