Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sceUtilityLoadNetModule, audio and thread issue #144

Open
Fewnity opened this issue Jul 9, 2023 · 5 comments
Open

sceUtilityLoadNetModule, audio and thread issue #144

Fewnity opened this issue Jul 9, 2023 · 5 comments

Comments

@Fewnity
Copy link

Fewnity commented Jul 9, 2023

I have noticed a problem with sceUtilityLoadNetModule.

If I load PSP_NET_MODULE_COMMON and PSP_NET_MODULE_INET and then I call pspAudioInit(), I will not be able to create a thread with sceKernelCreateThread. If a thread already exists in my game, it will be stopped.
sceKernelCreateThread will always return a negative thread id.

sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
sceUtilityLoadNetModule(PSP_NET_MODULE_INET);

pspAudioInit();
SceUID thd_id = sceKernelCreateThread("thread1", thread1, 0x38, 0x10000, 0, NULL);
if (thd_id >= 0)
{
    sceKernelStartThread(thd_id, 0, 0);
}
else
{
    pspDebugScreenPrintf("Bad thread id\n");
}

This should prints Bad thread id.

I don't have a PSP 2000/3000 to test but I have the problem on my PSP 1000 and Street. My FW version is 6.61.
I think there is an issue with sceUtilityLoadNetModule or something else about network because most of network samples do not work on my PSP 1000, see: #45 (comment)

Small compilable sample code with the issue (there is a precompiled EBOOT too): No_Thread_Issue.zip

@diamant3
Copy link
Member

diamant3 commented Jul 10, 2023

I tried this on my PSP 1000(6.60 PRO-C) but unfortunately, it prints Bad thread id too.

@diamant3
Copy link
Member

Hello, Did you already fix this? I tried this again but this time I just set like this to sceKernelCreateThread("thread1", thread1, 0x38, 0xfa0, 0, NULL);, same initial stack size of your callback thread and it works!

Device: PSP 1000(6.60 pro-c)

@Fewnity
Copy link
Author

Fewnity commented May 8, 2024

I was able to fix the issue by adding PSP_HEAP_THRESHOLD_SIZE_KB(1024); in my main.cpp
I'm not closing the issue because I think what I found is just a workaround, and there is probably a bug in the sdk.

@John-K
Copy link
Member

John-K commented May 15, 2024

I suspect this is due to the default heap being set to only 512KB.

I haven't dug into exactly how all of the allocations happen for the Net stack, but it doesn't seem all that strange to think that you're bumping up against that limit.

I'm not sure if we should change the default here, or if we should add a warning..

@Fewnity
Copy link
Author

Fewnity commented May 15, 2024

Maybe change default value and add a warning, because I'm not the only one with this problem. I think both are important. It was annoying to thing a fix and an explaination for this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants