Homebrew Need help with what I think could be a ctrulib bug

nop90

Well-Known Member
OP
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
I found a strange bug in all my homebrew in CIA format.

While in the homebrew, if I pres the home button the system opens the home menu, from here if I close the 3ds case and then open it again, both screens remain black and the system seems to be frozen.

It doesn't seems to be a problem in my code, but before opening an isuue on the ctrulib github I ask the devs of the forum to check it.

The problem happens with the following simple code too:

Code:
#include <stdio.h>

#include <3ds.h>

//----------------------------------------------------------------------------
int main(int argc, char **argv) {
//----------------------------------------------------------------------------

   PrintConsole topScreen;

   gfxInitDefault();

   consoleInit(GFX_TOP, &topScreen);

   consoleSelect(&topScreen);

   printf("Press START to exit\n");

   int i=0;
   while(aptMainLoop()) {

     gfxSwapBuffers();
     gfxFlushBuffers();
     gspWaitForVBlank();

     hidScanInput();
     u32 kDown = hidKeysDown();

     if (kDown & KEY_START)
       break; // break in order to return to hbmenu

   printf("%i\n",i++);

   }

   gfxExit();
   return 0;
}

You can find attached the rsf file I used for the test (UniqueId 0xffff that I use to test pre release cias)

Maybe it isn't a ctrulib problem but only of my CFW version (it's RXTool, I know it's outdated, but I use it only to test my hoembrew in CIA format)

If you have time please test this simple homebrew and tell me if the problem happens with your CFW and ctrulib version.

Thanks in advance. NOP90
 

Attachments

  • ciatest.zip
    2 KB · Views: 120

Sono

cripple piss
Developer
Joined
Oct 16, 2015
Messages
2,825
Trophies
2
Location
home
XP
9,375
Country
Hungary
I can confirm this is an issue! And I think I know why!

You see, ctrulib only processes APT events in aptMainLoop(), but if you are in the home menu, iirc the main thread gets suspended.
In official applications, APT events are handled by a separate thread which is NOT suspended when you suspend the application, meaning if you close the lid, and open it back, it's still handled by the application.

Also, this is both the 3DS's fault, and ctrulib's fault :P
 

nop90

Well-Known Member
OP
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
So to solve ithis we could create in the app a separate thread that hadles the exiting from the sleep mode, and inserting a sleep() call in the aptmainloop() function to make run the second thread.

What about it?
 

Sono

cripple piss
Developer
Joined
Oct 16, 2015
Messages
2,825
Trophies
2
Location
home
XP
9,375
Country
Hungary
So to solve ithis we could create in the app a separate thread that hadles the exiting from the sleep mode, and inserting a sleep() call in the aptmainloop() function to make run the second thread.

What about it?

Well, ye, we could replicate how official apps do it, but if your app crashes, and you try to return to *hax, then it'll still run in the background, causing many troubles, so it doesn't sound like a good idea :/

I mean, technically we can detect if we're running as a .cia, so it should be possible to make or not make a thread for APT, depending on how you run the program.
 

nop90

Well-Known Member
OP
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
After opening an issue on ctrulib github, Fincs informed me that this problem has been solved in ctrulib at the end of july, so updating ctrulib solves the problem.

I tested it and can confirm that now everything works fine.
 
  • Like
Reactions: hippy dave

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Psionic Roshambo @ Psionic Roshambo:
    That Dell data breach is worse than people probably realize....
  • Psionic Roshambo @ Psionic Roshambo:
    When I worked for Dell we had access to data about military contracts and addresses for high ranking people.
  • Psionic Roshambo @ Psionic Roshambo:
    I personally handled a call from the second highest person at Raytheon. That call bothered me a lot... The guy was nice and smart what bothered me was the way management basically just blew him off instead of going the extra mile to help him.
  • Psionic Roshambo @ Psionic Roshambo:
    In the end that call ended up costing Dell millions in lost contracts with Raytheon, and really the issue could have been solved for like 450 bucks lol
  • NinStar @ NinStar:
    sometimes I wonder why anyone would ever buy mega man x legacy collection 2
  • NinStar @ NinStar:
    I always thought that capcom shuffled the games in these collection, but apparently they are all in chronological order, which makes legacy collection 2 worthless
  • BakerMan @ BakerMan:
    guys, i want to start singing pirate metal songs and sea shanties if i play sea of thieves
  • The Real Jdbye @ The Real Jdbye:
    find a pirate metal playlist
    +2
  • The Real Jdbye @ The Real Jdbye:
    and sing along
  • BakerMan @ BakerMan:
    nevermind i just learned swearing is against the rules in sea of thieves

    i was about to start singing the song i last put in "what song are you currently listening to" yesterday
  • BakerMan @ BakerMan:
    but yeah ig so
  • The Real Jdbye @ The Real Jdbye:
    swearing not allowed in a pirate game? what has the world come to
  • BakerMan @ BakerMan:
    (here's the song for context)
  • BigOnYa @ BigOnYa:
    Just add -izle to the end of every curse word, you will be fine.
    +2
  • The Real Jdbye @ The Real Jdbye:
    i like alestorm
    +1
  • The Real Jdbye @ The Real Jdbye:
    @BigOnYa too many syllables
    +1
  • BakerMan @ BakerMan:
    same lmao
  • BigOnYa @ BigOnYa:
    hi, welcome to the Temp!
    +1
  • BakerMan @ BakerMan:
    Welcome to the Underground!
    +1
  • BakerMan @ BakerMan:
    the booty boogie from (once again) the donkey kong country cartoon could also be a good song to sing while playing sea of thieves
  • BigOnYa @ BigOnYa:
    Please insert 25 cents for an additional 30 minutes of talk time.
    +2
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=tG7fk_DUz5g +1