spice2x / spice2x.github.io

🌶️ spice2x is a spicier fork of SpiceTools with hundreds of bug fixes and new features 🌶️
https://spice2x.github.io/
GNU General Public License v3.0
117 stars 2 forks source link

IIDX will no longer start if iidxtdjcamhook is enabled. #209

Closed aerithg closed 3 months ago

aerithg commented 3 months ago

Game and version

IIDX 31 EPOLIS

Version of spice2x

spice2x-24-08-03

Describe the issue

With spice2x-24-07-29, the game started without any problems even with the camera enabled, but with spice2x-24-08-03, the game no longer starts when iidxtdjcamhook is enabled. The game starts normally when iidxtdjcamhook is disabled, so this is probably a bug.

I set it to "-loglevel all".

Startup successful spice2x-24-07-29log.txt

Startup failure spice2x-24-08-03log.txt

sp2xdev commented 3 months ago

Can you set -loglevel to all and try sharing the log again? Thanks.

Maybe a log file from the previous version might help as well.

If you have %appdata%\spicetools_camera_control.json, try deleting it.

aerithg commented 3 months ago

The log file has been updated, please check it.

guardianblue commented 3 months ago

The log file has been updated, please check it.

there are 3 cameras and maybe the logic was not robust enough to handle that

i will look into and make a patch

sp2xdev commented 3 months ago

The log file has been updated, please check it.

there are 3 cameras and maybe the logic was not robust enough to handle that

i will look into and make a patch

I tried plugging in 3 cameras and it didn't crash, so seems like there is more to this.

guardianblue commented 3 months ago

The log ends at load config but I have a feeling that it is something else, probably with DXVA related code, as sometimes the log messages weren't flushed before the crash. For instance device manager doesn't need to be created per camera.

guardianblue commented 3 months ago

The log file has been updated, please check it.

spice2x-24-08-04.zip

This local build adds more debug messages, allow loading of camera config to fail gracefully, and only initialize D3DManager once.

While this build probably not likely to solve your start up crash, it should give us more information to troubleshoot with. Please kindly run it and send back logs.

aerithg commented 3 months ago

I tried installing it, but it didn't start. The log seems to have progressed a little.

spice2x-24-08-04log.txt

guardianblue commented 3 months ago

an error log is given about invalid characters... Does your windows username contain UTF8/16 characters?

also, please share your camera config json if you can

also, if you disable your front camera (the second one since you are flipping the cameras), would the game start?

i will give another build soon to see if the problem can be addressed

sp2xdev commented 3 months ago

Oof, this is where I realize the codebase uses std::getenv everywhere which is not unicode path friendly.

aerithg commented 3 months ago

I don't know the details, but my username is definitely in Japanese. I thought about changing it to English, but it seemed a bit difficult so I gave up. Sorry.

How do I disable the front camera?

guardianblue commented 3 months ago

I don't know the details, but my username is definitely in Japanese. I thought about changing it to English, but it seemed a bit difficult so I gave up. Sorry.

How do I disable the front camera?

no worries, this is definitely helpful

to disable the camera(s), either unplug them physically, or disable them through device manager

aerithg commented 3 months ago

This is the log after physically removing them and leaving only one camera. This also did not start up.

log.txt

aerithg commented 3 months ago

This may be a different problem, but I noticed when I checked the spice2x-24-07-29 version with one camera.

When there was only one camera, the game started, but the camera remained still and did not function properly. When there were two cameras, it worked properly. (spice2x-24-07-29) With spice2x-24-08-04, I cannot get it to start even with one or two cameras.

log.txt

sp2xdev commented 3 months ago

I'm surprised that you aren't having more trouble - for example, I thought spicecfg would fail to save the config file to disk.

edit: yep, if your username in users directory is non-Latin, spice immediately crashes, so I feel like this exception is not necessarily tied to this issue.

guardianblue commented 3 months ago

I think there are 2 issues here:

  1. utf8 path in config file, which I think deserves a separate issue to tackle properly as a whole
  2. one of the camera failed to complete IIDXLocalCamera constructor, and it was still going through the second part of the initialization, causing the exception. This I will provide a patch here soon.
guardianblue commented 3 months ago

This may be a different problem, but I noticed when I checked the spice2x-24-07-29 version with one camera.

When there was only one camera, the game started, but the camera remained still and did not function properly. When there were two cameras, it worked properly. (spice2x-24-07-29) With spice2x-24-08-04, I cannot get it to start even with one or two cameras.

log.txt

~spice2x-24-08-06.zip~

Please give another try.

Changes:

  1. Avoids hard crashing if the config file cannot be loaded
  2. Do not start capture if initialization fails
  3. Add more logs to show the results of each initialization step

@sp2xdev one thing comes into my mind, that log_* marco doesn't seem to obey the log level flag. They would all appear in the log. Is that by design?

aerithg commented 3 months ago

Thank you. I tried it right away.

It now launches normally when two cameras are attached. However, it seems to crash as before when only one camera is attached.

Successful launch log with two cameras spice2x-24-08-06_2camera_log.txt

Crash log with one camera spice2x-24-08-06_1camera_log.txt

guardianblue commented 3 months ago

spice2x-24-08-06.zip

@aerithg I am sorry that the previous zip I sent out did not contain the fix. Please kindly try again to see if this works. Thanks!

You should be able to see something in the log in this version: (logs would have [top] / [front] to tell which camera it is working with)

[2024/08/06 15:26:18] I:iidx::tdjcam: MFEnumDeviceSources returned 1 device(s)
[2024/08/06 15:26:18] I:iidx::tdjcam: [top] Creating camera
[2024/08/06 15:26:18] I:touch_indicators: disable visual feedback for touch events for HWND=0x7096e
[2024/08/06 15:26:18] I:bi2x_hook: aioIob2Bi2x_WriteFirmGetState
[2024/08/06 15:26:18] I:bi2x_hook: aioIob2Bi2x_OpenSciUsbCdc
[2024/08/06 15:26:18] I:bi2x_hook: aioNMgrIob2_Create
[2024/08/06 15:26:18] I:bi2x_hook: AIO_NMGR_IOB::BeginManage
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] Activated
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] Symlink: \\?\usb#vid_046d&pid_0893&mi_00#9&41c76c0&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\global
[2024/08/06 15:26:18] M:iidx::tdjcam: Created DeviceManager for DXVA
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] Created source reader
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] Created texture
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] Init camera control
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] >> Pan range=(-10, 10) default=0 delta=1 dFlags=2 value=0 vFlags=2
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] >> Tilt range=(-10, 10) default=0 delta=1 dFlags=2 value=0 vFlags=2
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] >> Roll range=(-180, 180) default=0 delta=90 dFlags=2 value=0 vFlags=2
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] >> Zoom range=(100, 400) default=100 delta=1 dFlags=2 value=100 vFlags=2
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] >> Exposure range=(-11, -2) default=-5 delta=1 dFlags=3 value=-5 vFlags=1
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] >> Iris range=(0, 0) default=0 delta=0 dFlags=0 value=0 vFlags=0
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] >> Focus range=(0, 255) default=0 delta=1 dFlags=3 value=0 vFlags=1
[2024/08/06 15:26:18] M:iidx:tdjcam: [top] Initialized
[2024/08/06 15:26:18] I:iidx::tdjcam: loading config
[2024/08/06 15:26:18] I:iidx::tdjcam: Parsing config for: \\?\usb#vid_046d&pid_0893&mi_00#9&41c76c0&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\global
[2024/08/06 15:26:18] M:iidx::tdjcam:   >> done
[2024/08/06 15:26:18] M:iidx::tdjcam: [top] Find best media type
[2024/08/06 15:26:18] I:iidx::tdjcam: [top] Use media type from config 1280x720 @30FPS NV12
[2024/08/06 15:26:18] I:iidx::tdjcam: [top] Change media type: 1280x720 @30FPS NV12
[2024/08/06 15:26:18] I:iidx::tdjcam: [top] Creating thread
sp2xdev commented 3 months ago

utf8 path in config file, which I think deserves a separate issue to tackle properly as a whole

Yep - please see #210, hopefully this is already fixed.

@sp2xdev one thing comes into my mind, that log_* marco doesn't seem to obey the log level flag. They would all appear in the log. Is that by design?

Yes, that is the case - logs generated by spice itself don't get filtered by the log level, only the ones generated by the game does. It's an odd choice made by the original devs but I'm totally fine with the way it is right now.

aerithg commented 3 months ago

I have confirmed that it works with the above file.

This time, the game itself starts up properly whether there is one or two cameras. The only other issue seems to be the camera not working when there is only one camera.

LOG for 2 camera spice2x-24-08-06_2camera_log.txt

LOG for 1 camera spice2x-24-08-06_1camera_log.txt

guardianblue commented 3 months ago

I have confirmed that it works with the above file.

This time, the game itself starts up properly whether there is one or two cameras. The only other issue seems to be the camera not working when there is only one camera.

LOG for 2 camera spice2x-24-08-06_2camera_log.txt

LOG for 1 camera spice2x-24-08-06_1camera_log.txt

glad to know it somehow works for you now

for the case where 2 cameras vs 1 camera, if you look at the log, the system actually returns 3 cameras when you plugged both physical cameras. Spice only process the first 2, therefore it skipped the problematic entry when you plugged both cameras on.

I will change the logic so that it will skip a camera gracefully and try the next one.

guardianblue commented 3 months ago

fix-incompatible-cam.patch

  1. Move D3D Manager logic to camera.cpp
  2. Add log messages to different stages of camera initialization
  3. If the initialization of a camera fails, try with the next camera without crashing
  4. Fixed a bug where "AllowManualControl" config is not loaded correctly

@sp2xdev this patch is based on 2024-08-06 release

sp2xdev commented 3 months ago

Merged, thanks for the fixes.