#quiz game freeze

1 messages · Page 1 of 1 (latest)

keen granite
#

^thread

dense bolt
#

okay okay

keen granite
#

can you show me this window?

dense bolt
#

how?

keen granite
#

screenshot it

dense bolt
#

oh wait

keen granite
#

on windows, Win + Shift + S will let you clip part of your screen and then paste it

#

quiz game freeze

dense bolt
#

uhhh its not frozen yet

#

wait up imma make it freezee

keen granite
#

ah, it broke in some random other thread

#

this won't be relevant, yeah

dense bolt
#

wait it breaks now

keen granite
#

hit Continue to let the editor resume

dense bolt
#

i'll press the pause?

keen granite
#

then make the game freeze and pause in VS

dense bolt
#

okay i did it

keen granite
#

you may need to switch the thread you're viewing if it paused on the wrong one again

dense bolt
#

i have this

keen granite
#

click on the Thread dropdown

#

what options does it give you?

dense bolt
keen granite
#

those are some great names lol

#

scroll up

dense bolt
#

i dont know that those means tbh

#

i didn't set up those

keen granite
#

scroll all the way up

#

they're all unity-internal stuff

dense bolt
dense bolt
keen granite
#

wait, can you show me how you attached to unity?

dense bolt
#

i pressed that thing

#

attach to unity button

keen granite
#

okay, so that should be right

dense bolt
#

i'm reloading the editor

#

okay so what now?

keen granite
#

make sure that the editor is in Debug Mode, run the game, and Attach to Unity in VS

#

don't make the game freeze yet

dense bolt
#

i think the checker one if fucking it up tbh

#

wait up

keen granite
dense bolt
#

okay okay

#

its compiling

#

but its yellow

#

after i attach it should be green right?

keen granite
#

oh, is it yellow?

dense bolt
#

its blue now

keen granite
#

i'm red-green colorblind lol

dense bolt
#

after i attach its blue

#

oh shit

keen granite
#

that sounds promising

#

did it behave better this time?

dense bolt
#

wait i'll try to press the buttons again

#

oh wait

#

i didnt pressed play

#

okay its still blu

keen granite
#

once you enter play mode, try pausing in VS

dense bolt
#

okay i'll pause now

keen granite
#

see if it actually has a main thread this time

dense bolt
#

its still frame not i module

dense bolt
keen granite
#

hm, that's not very useful

#

tell you what -- i'm going to go set this up correctly on my PC and try debugging myself

#

what version of unity is this?

dense bolt
#

2022.2.5f1

keen granite
#

gotcha

dense bolt
#

is there a better way to do the not giving the prev asnwers?

#

if that's the problem i guess that's what should i replace

keen granite
#

I guess I'd just make a list of all things you haven't asked yet

dense bolt
#

i mean question

keen granite
#

and then remove things from the list as you ask them

dense bolt
#

uhhh sure

keen granite
#

i'm really curious what the problem is with the debugger tho

#

it's very useful for tracking down things that make the editor freeze/crash/instantly close

dense bolt
#

ohhh i see

#

yeah its been bugging me in the last 2 - 3 days with this error

#

but it works when i remove the popup of the panel

#

should i try it on my phone and see if it works?

keen granite
#

oh, that's a useful thing to know

keen granite
dense bolt
#

yeah the whole making timerGo change to 2

#

so the update doesnt process

keen granite
#

ah, this looks familiar

dense bolt
#

nope still freezes

#

so i guess its the retaining the question thingy?

keen granite
#

so I wrote some code that freezes the game

#

if I execute that and then hit the pause button, it does show me the right stuff

dense bolt
#

yeah mine doesnt

keen granite
#

normally, when you break, you catch the game while it's just sitting around

#

waiting for the next frame

#

that explains what you're seeing, at least...although it is weird that nothing changes when the game is frozen

dense bolt
#

yeah

#

can we just focus on the checking the prev question? on how that does the infinite loop?

#

i think that is the cause of the infinite loop

keen granite
#

you could rule it out by removing the check

#

normally, I'd be trying a debugger after this kind of thing fails to find the problem, but I guess we're doing it backwards today 😛

dense bolt
#

alright i'll try it

keen granite
#

oh yeah, one other thing you might try with debugging

dense bolt
#

AHHAHAHA welp my code editor is not funcitoning properly

keen granite
#

if you right click on a line and add a breakpoint, then attach the debugger, it will auto-break when it hits that line

#

so, if I were using the debugger, I'd put a breakpoint on the function that checks for a duplicate

#

and see if it runs over and over

dense bolt
#

i see

#

btw

#

yeah it works perfectly without the checker of the prev question

#

so wdyt?

keen granite
#

okay, so that's the prime suspect

#

the question, though, is why it's getting stuck like this

#

it just stops you from getting the same one twice

#

even if there are only 5 choices, the odds of it getting stuck for a long time are insanely low

dense bolt
#

yes

#

should i add tostring ?

#

just like this

#
ansHandler = shapes[randomButtonShape].ToString();
#

does this help?

#

because the ansHandler is a string to begin with

keen granite
#

nope, that shouldn't be relevant

dense bolt
#

yeah i just came up with that loop

keen granite
#

if you want to catch it in action, maybe add a static int that counts how many times you've checked the answer

#

throw an exception if it gets over, say, 25

dense bolt
#

but if you have a better loop process that would be really helpful for my thesis

keen granite
#

and log the values at each step

#

you should see some kind of interesting pattern

#

like it picking the same string every time

dense bolt
#

yeah i tried that

#

like a string to check if what is being added to the string

#

and it still freezes before throwing back

keen granite
#

did you add a hard limit for the number of tries?

dense bolt
#

havent done that yet

#

should i try?

keen granite
#

like

public static int tries = 0;

[...]

void CheckAnswer(string str) {
  ++tries;
  Debug.Log(str);
  if (tries >= 25)
     throw new Exception();
}
dense bolt
#

i'll try that now

#

yeah it just freezes

#

i added a failsafe

#

but it still freezes

keen granite
#

show me what you wrote

dense bolt
#
        if(newAns == prevAnswer)
        {
            tries++;
            if (tries == 25)
            {
                checkertries.text = tries.ToString();
                ansIfGo = true;
                questionRandom();
            }
            checkertries.text = tries.ToString();
            ansIfGo = false;
            questionRandom();

        }
#

something like this

#

didnt add the throw

keen granite
#

i would just throw an exception

#

completely bail out

dense bolt
#

how do you add that again to a method?

keen granite
#

throw new Exception()

#

also, don't make this conditional

#

put this right at the start of the checker method

#

so that, no matter what, it can't run more than 25 times

dense bolt
#

like this?

#
void prevAnsCheck(string newAns) throws new Exception()
keen granite
#

ah, no, you don't add anything to the declaration

dense bolt
#

i think this is wrong

#

AHAHHAHHA

keen granite
#

this isn't Java

dense bolt
#

oh yeah

#

wait ill try again

#

ayo wtf?

keen granite
#

you've got a typo somewhere

#

enter safe mode, fix the errors, and it'll load

dense bolt
#

aight i'm in

#

i'll try this

#

wait

#

okay

#

the shit didnt change

#

this means the error occured

#

and i have the error on the code/unity

#

editor didnt freeze

keen granite
#

so the editor didn't freeze this time

#

that's good; we caught it

dense bolt
#

but i have an error

#

yes

#

so its the loop

keen granite
#

did you log the string it was trying each time?

dense bolt
#

yes

#

oh shit

#

i added the throw before the count

#

lmao

#

wait up

#

i'll run it again

#

alright now i thrown it after the counter

#

but its still 0

#
    void prevAnsCheck(string newAns)
    {
        
        if (newAns == prevAnswer)
        { 
            tries++;
            if (tries == 25)
            {
                checkertries.text = tries.ToString();
                throw new System.Exception();
                ansIfGo = true;
                questionRandom();
            }
            checkertries.text = tries.ToString();
            ansIfGo = false;
            questionRandom();

        }
        else
        {
            checkertries.text = tries.ToString();
            ansIfGo = true;
        }
    }
#

heres the code

keen granite
#

"it's still zero?"

dense bolt
#

yes

keen granite
#

i do not understand

#

what is still zero?

dense bolt
#

the tries counter

keen granite
#

ah, you added some text for it

dense bolt
#

yes

#

but its still 0

#

when i tried this code it just hangs

dense bolt
#

or freezes

keen granite
#

move this out to the very top of the function

#
            if (tries == 25)
            {
                checkertries.text = tries.ToString();
                throw new System.Exception();
            }
dense bolt
#

okay okay

keen granite
#

and increment tries up top, too

#

so that, no matter what, it does ++tries every time you call the function

dense bolt
#

okay i'll try it

#

wait

#

wtf

#

it doesnt do the freezing shit

#

wait

#

the loop is working

#

and it just loops for 1 time

#

i had a debug there to print the tries

#

oh

#

i removed the call

#

fuck

#

wait

#

there we go it freezes again

#

but the throw doesnt make it stop or resets

#

basically the part of tries == 25 is not being used

#

it just freezes

keen granite
#

this is making me think it's happening somewhere else

dense bolt
#

like where

#

changing the sprite?

keen granite
#

You might need to go back to the debugger and add a breakpoint somewhere in the answer picking function

#

and then step through it to see where it’s getting stuck

dense bolt
#

damn

keen granite
#

Adding a breakpoint should make it actually find your code

dense bolt
#

do you have a better way to do this looping thing for the question?

#

if its not a ahassle to you i'd be glad if you have a different method

dense bolt
#

i just fixed it

#

i removed the function

#

and just added the loop inside itself

#

something like this

#
    void questionRandom()
    {
        randomNumber = Random.Range(0, 3);
        randomButtonShape = Random.Range(0, maxRangeShape);
        ansHandler = shapes[randomButtonShape];
        if(ansHandler == prevAnswer)
        {
            Debug.Log(shapes[randomButtonShape]);
            questionRandom();
        }else if (ansHandler != prevAnswer)
        {
            Debug.Log(shapes[randomButtonShape]);
            questionNumber = questionNumber + 1;
            currentNum.text = questionNumber.ToString();
            randomBtns();
        }
    }
#

thank you

keen granite
#

ah, so it just calls itself now?

#

that is closer to how I'd do it, yeah