Sewer56 / FileEmulationFramework

Framework for emulating files using Reloaded-II.
GNU Lesser General Public License v3.0
7 stars 7 forks source link

AWB Emulator can't read file on Proton, makes a few mods incompatible. #3

Open snoandpetals opened 1 year ago

snoandpetals commented 1 year ago

Under all tested proton versions, the AWB Emulator can't seem to read/edit ACB files. This makes a few mods (and potentially future mods) incompatible with Linux.

Tested Proton Versions GE-Proton7-49 GE-Proton7-42 Proton Experimental Proton 7.0-6

Affected Mods

Randomized Battle Music - Music doesn't play when in battle image (1)

P5R Custom Bonus Tweaks - Music doesn't play image

Sewer56 commented 1 year ago

I'm aware of a small oversight in this project; I'll respond in here when I fix it. Hopefully this week.

Sewer56 commented 1 year ago

Hmm, alright; I thought there was an oversight, but seems I did account for that little something I was thinking of.

Here's something to do:

Can you do the following?

I'll probably need to make some custom builds after that; but it should provide me the initial needed info.
I take Linux compatibility pretty seriously; so if it comes down to it, am happy to even set up a fresh Linux environment just to debug through this.

snoandpetals commented 1 year ago

I've made two logs, one with both of the requested mods log levels set to debug, the other one being just your regular Information level log. Weirdly enough, the text that says "Can not open file." is not present in the information log. I hope this helps nonetheless! (And sorry for the wait, navigating on Deck is a bit difficult haha)

modlist.json is formatted as a txt since github won't let me send jsons here, apologies.

infolog.txt debuglog.txt modlist.txt

What the console looks like (Contains lines that the info log doesn't, for some reason???) EDIT: this screenshot is the Information level log, not debug Screenshot_20230318_203939

Sewer56 commented 1 year ago

Alright; I'll have a read through later today; and walk through the code to see potential culprits. I'll let you know if I'll need any more info.

MrCamel999 commented 1 year ago

Not sure if this helps at all, but I was trying to get the Battle Music Randomizer to work myself through Proton, and it seems the 1.0 0 version of the mod works. It may use something different that is unrelated and that's why it works, but maybe that helps somewhat

Sewer56 commented 1 year ago

1.0.0 of which specific mod? Might be helpful with narrowing things down.

Am finishing Virtual Filesystem work [I wanna get it done while the complicated stuff's in my head]; and tomorrow I'll probably be getting a live Linux setup going for debugging.

Sewer56 commented 1 year ago

Note to self:

Also Hook NtQueryDirectoryFile(Ex) not just NtQueryInformationFile Also Hook NtQueryDirectoryFile(Ex) not just NtQueryInformationFile Also Hook NtQueryDirectoryFile(Ex) not just NtQueryInformationFile Also Hook NtQueryDirectoryFile(Ex) not just NtQueryInformationFile Also Hook NtQueryDirectoryFile(Ex) not just NtQueryInformationFile Also Hook NtQueryDirectoryFile(Ex) not just NtQueryInformationFile Also Hook NtQueryDirectoryFile(Ex) not just NtQueryInformationFile

Maybe it's related, maybe it's not. Repetition for emphasis, I don't want to forget.

snoandpetals commented 1 year ago

1.0.0 of which specific mod? Might be helpful with narrowing things down.

Am finishing Virtual Filesystem work [I wanna get it done while the complicated stuff's in my head]; and tomorrow I'll probably be getting a live Linux setup going for debugging.

I believe the mod in question is https://gamebanana.com/mods/412327, Battle Music Randomizer 1.x.x used a different method than what 2.x.x uses for randomizing the music. Looking at the files it's hard to discern what the actual difference is, but the 2.x.x builds include a BGM.acb as well as BGM_01 awb and acb. The 1.x.x builds don't contain the BGM.acb file, but do contain the BGM_01 files. 2.x.x also allows the user to modify which BGMs are played within an ingame menu, meaning you don't have to restart the game.

Sewer56 commented 1 year ago

Alright; that actually provides a bit of useful context. The intended behaviour is that if a custom ACB already exists; it should be patched instead of the original one in the CPK. I wonder if some logic around that isn't translating nicely.

I'll note that when I get around testing.

Sewer56 commented 1 year ago

Sorry for the delay; I've been going crazy trying to finish up Virtual Filesystem stuff; took longer than expected. I'll need to test that on Wine too; so I'm going to be setting up a proper *nix setup for testing. I didn't forget.

snoandpetals commented 1 year ago

Don't feel rushed! Glad to hear you're passionate about Linux support, though, means a lot to the Linux and Steam Deck community lol Thank you again

Sewer56 commented 1 year ago

Okay, an update on this; and this is unfortunate.

I spent the last 2.5 months or so working on a Virtual FileSystem: https://reloaded-project.github.io/reloaded.universal.redirector/index.html ; and I wanted to get this released today.

Then fix the issue here; as I would be then using said project to improve load times in CriFsHook, which uses FileEmulationFramework, so I'd also be looking at this at the same time.

Unfortunately, due to low level GC related shenanigans in C#, the upgrade to the Redirector (now full FileSystem) breaks in Wine...

vmplayer_ejzhtBh5am

Which means I can't release it; and I can't work on this right now, as I'll need to port the VFS to native code (I'll be going with Rust). This is a bummer... I already have a huge backlog; and now it's going to go up by another month :(

snoandpetals commented 1 year ago

Dang :( gotta love wine issues :( if I got this right, the entire VFS you've been working on just doesn't work on wine due to C#, so you have to spend a lot of time porting it to rust now? That sucks for sure :( Thanks for the update, though.

Sewer56 commented 1 year ago

Technically it's not Wine's fault; it's just that with the way things are set up under the hood in Wine; it replicated on Wine first.

Using .NET to hook Windows OS functions that the native runtime can call (under some circumstances) is not safe; but I've been doing that regardless (in this case to save time), and now I'm paying the cost. This code was always going to possibly break after a major runtime upgrade; I did not expect it to break under Wine however.

FileEmulationFramework itself is also prone to this!! I will be rewriting both so I won't have to deal with this again in the future. It will take a long time however...

snoandpetals commented 1 year ago

Well this is odd, with crifs hook 2.1.6, the music changes in Custom Bonus Tweaks loads in 50% of the time... There's no discernible pattern as to why it loads in fine, it's seemingly random. Same situation for both Gaming mode and Desktop mode

Still not ideal, and I don't know if this information changes anything.

By the way, what does error 32 actually mean? Is it windows' error 32: ERROR_SHARING_VIOLATION? Or a different error altogether?

Sewer56 commented 1 year ago

Good question: If it's in the log, it's probably a CRI error.

snoandpetals commented 1 year ago

Wait, if it's a CRI error, doesn't that mean the problem more lies with CRI and not the File System Emulator? And then there's the fact it works sometimes but not others... If error 32 is similar to windows' in any way, it might mean that CRI is trying to access the ACB file before the File System Emulator can close out of it? Or do you know for a FACT it's a .NET with wine issue? Idk, I'm just trying to think of some ideas ;P How's progress on the rewrite btw? (if you haven't been too busy doing other things, I see how many commits you make per day and you've definitely got a lot of motivation for modding, huge respect ;P)

Sewer56 commented 1 year ago

My long term plan is the following:

Give-take 6-8 months most likely.

There was a recently found oversight in FileEmulationFramework; with a fix coming soon; it might be related to what's being experienced here under Proton (don't yet know). It should land when @AnimatedSwine37 rolls out .bf emulator for Persona.

Otherwise, I'll probably only look at this after the Rust port, before R3 development.

snoandpetals commented 1 year ago

Thanks for the roadmap! Sorry, I didn't mean to seem like I was rushing you or anything haha, you already do a LOT for the modding community, huge respect ;P Thanks for all your work 🙏

Sewer56 commented 1 year ago

It's a-ok. It's gonna be a long way ahahaha; I'll get there eventually :p

snoandpetals commented 12 months ago

I think whatever was changed in CriHooksV2 2.2.1 and PersonaEssentials 2.5.0 actually fixed this problem! I ran 12 tests with the Custom Bonus Tweaks mod, all of which loaded the audio perfectly. (This time I made sure I had the mod actually loaded lmfao.)

Beforehand, the audio would only load about 35% of the time, so either I'm getting incredibly lucky this morning or whatever you did fixed this issue.

I'm comfortable closing this issue if you are! (if I start encountering it again I'll reopen the issue but so far smooth sailing)

Sewer56 commented 12 months ago

That would at least be a very funny coincidence

snoandpetals commented 12 months ago

The reason I made the other issue report in the first place is because I was testing if this was fixed, considering the updates to Cri Hooks seemed to be file-loading related ;P (but then forgot to actually load the mod...)

I have a theory that maybe the loading time was upsetting proton for whatever reason. I mean, before the update, it loaded 35% of the time which could be variation in load-speed, and having it load faster now might've actually fixed it (or maybe it was just incredible coincidence that whatever changes you made, made proton happy)

Buuuuut I'm no expert whatsoever. Feel free to test on your own system to make sure I'm not just getting INCREDIBLY lucky or going insane ;P

Sewer56 commented 12 months ago

The entire process of loading files has been completely reworked in CriFsV2Hook; from relying on CRI's implementation of binding folders and symlinking into that, to binding files directly and hooking the CRI internals to redirect loads for custom files (to solve the 'can only load files relative to game folder' issue).

There's a lot more code now involved, especially for fixing case sensitivity, as CRI is case sensitive (but users expect files to work with any case); and having to handle edge cases such as people having non-ANSI (Unicode) characters in their paths to games. It took a bit of effort to get going; but I just had an idea one day for a portable enough solution that didn't involve a Virtual FileSystem, and well, here I am, hahaha.

If it ended up fixing anything else in the process; that's a really good benefit. Part of me was sweating a lot, worried there might be unexpected breaking changes with the release.

snoandpetals commented 12 months ago

Part of me was sweating a lot, worried there might be unexpected breaking changes with the release.

LOL sorry for the scare earlier then ;P (gotta love human error...) it's running faster and better from what I can tell, so you really did a good one with this update

MrCamel999 commented 11 months ago

I just got around to trying this on my system and unfortunately still have issues. I don't use Custom Bonus Tweaks specifically, but rather the Battle Music Randomizer mod. The 2.1.1 version just won't let me launch the game, it will crash instantly, and the 1.0.0 version will only sometimes launch with game audio

Sewer56 commented 11 months ago

I guess I'll leave it open then.

MrCamel999 commented 11 months ago

Sorry to spoil the victory! I was very excited to try it again lol, but oh well, life is life

snoandpetals commented 11 months ago

The 2.1.1 version just won't let me launch the game, it will crash instantly, and the 1.0.0 version will only sometimes launch with game audio

The crashing seems like a different issue altogether, the original issue only made it so audio would just not load... I am curious about the 1.0.0 version though, you're saying it will only sometimes launch with game audio? Meaning sometimes it'll launch without audio?

MrCamel999 commented 11 months ago

The 2.1.1 version just won't let me launch the game, it will crash instantly, and the 1.0.0 version will only sometimes launch with game audio

The crashing seems like a different issue altogether, the original issue only made it so audio would just not load... I am curious about the 1.0.0 version though, you're saying it will only sometimes launch with game audio? Meaning sometimes it'll launch without audio?

It does seem like a different issue, you're right. I haven't had it crash before trying it this time, not sure why that is.

As for the 1.0.0 version, it will launch without audio the majority of the time, just as described in the original issue, which is the main reason why I commented here again when I encountered failure again of the same kind.

snoandpetals commented 11 months ago

I'm currently running Battle Music Randomizer 1.5.0 myself with no issues (ran about 5 times, worked good each time), could I get your Proton version, Persona Essentials version, and CRI FileSystem V2 Hook version?

MrCamel999 commented 11 months ago

I'm currently running Battle Music Randomizer 1.5.0 myself with no issues (ran about 5 times, worked good each time), could I get your Proton version, Persona Essentials version, and CriFS.Hook version?

Sure thing. GE-Proton 47 is seemingly what I had it on, just switched to Experimental since that has to have been a while ago according just to my memory. Maybe that will work. CRI FileSystem V2 Hook is on 2.2.2, so that should be good, and Persona Essentials is on 2.5.2. Maybe it's also something specifically with the Battle Music Randomizer in versions 2.0 or higher? Will test here in a second

MrCamel999 commented 11 months ago

Update: On Proton Experimental I get the exact same results. Battle Music Randomizer version 2.1.1 crashes, 1.0.0 breaks music playing. Will try and find the 1.5.0 version since you're saying that version works. Will also try the latest GE Proton while I'm at it

snoandpetals commented 11 months ago

The weird thing is, the newer battle music randomizer actually works for me as well, and I'd have no idea why it doesn't for you... Personally I'm running GE-Proton8-13, maybe that'll make the difference for you? The nature of this issue is very weird, either way, sewer's rust ports should neutralize this issue...

snoandpetals commented 11 months ago

just in case this changes things, my load order is as below: ENABLED Persona Essentials 2.5.0 Battle Music Randomizer 1.5.0 / 2.X CRI Filesystem V2 Hook 2.2.1 DISABLED (or dark red which which i assume means it's a dependency for a loaded program) AWB Emulator for File System Framework 2.1.3 AWB Emulator Support for CRI FileSystem V2 Hook 1.1.2 BF Emulator for File Emulation Framework 1.0.0 File Emulation Framework: Base Mod PAK Emulator for File Emulation Framework

MrCamel999 commented 11 months ago

Yeah, still crashes on 2.x.x with that setup, even on the latest GE Proton. Same issue again with 1.0.0, still have yet to try 1.5.0, but will try that here shortly. It's very weird though that mine isn't working with the same versions though

snoandpetals commented 11 months ago

That's unfortunate :/ Besides what I've already listed, I have no idea how to help further. Sucks that this issue will have to remain open for a bit, hopefully the rust ports completely erase this issue haha...

MrCamel999 commented 11 months ago

Yeah. Thanks for the tips anyways! Can't hurt to have newer versions of things installed anyways! I am excited for the Rust version for sure!

MrCamel999 commented 11 months ago

Update with trying to get version 1.5.0 running. Sorry it took a while, had to go and do other things. Anyways, it crashed as well, but in a different way. The crash on 2.1.1 went and just crashed the whole game, but with 1.5.0, it closes the window where P5R is, but the window that shows up to load the mods in whenever you start the app stays there, and Steam says that P5R is still open, really weird.