Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

System.link with WebGl do not behave the same as on PC

Discussion in 'WebGL' started by Wulirocks, Jun 29, 2022.

  1. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    Just discovered that after 2 hours of investigation.

    I have a struct with a list of string property "walletID"(42 characters long)

    var cryptoId = titleDataAllCryptoUserID.SingleOrDefault(id => id.walletID == LoginLogic.wallletID);

    if (cryptoId == null ){
    }else{

    }
    The item I am looking for exist. I console logged the content of titleDataAllCryptoUserID on Chrome log console , and it is there.
    On WebGL however cryptoId returns null, looks like it is too much work for WebgL to test for a string with 42 characters.

    Of course on PC cryptoId return not null....

    I found some alternatives but quite complexe to achieve what could normally be done in 5 minutes...

    Any ideas why WebGl is in trouble here?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,053
    How do you generate the walletID in the first place? It‘s quite possible that WebGL simply does not support the necessary cryptographic assemblies.
     
    Wulirocks likes this.
  3. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    it is the result of the login fromChain SDK. but "walletID" is nothing but a string...
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,053
    does chain return a valid walletID to begin with? try logging what you retrieve and check for any rpc call errors.
     
    Wulirocks likes this.
  5. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    Sure, it does return a valid wallet ID, the sample scene is simple enough, and the login with Metamask works.
    For posterity, is someone read that post or have a similar bug... I bet there is a limitation with the amount of characters with WebGL.
    I can't test that now, but if I had to test or reproduce this bug,
    I would test with a hardcoded string variable of 42 character (leaving the crypto thing aside). Or maybe I would set a variable similar like "0x54d54ff5g4f5g4fg44..." I bet that would reproduce the bug.
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,053
    try logging the contents of the titleDataAllCryptoUserID collection and what the SingleOrDefault query returns

    it's certainly not going to be something as esoteric as "WebGL can't test a string longer than 40 characters for equality". Think about it, that would blow up in so many ways for so many users, it could not have gone unnoticed.

    PS: have you noticed your wallletID has three l ? Perhaps that is an issue.
     
  7. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    Of course I did that before posting here.
    Chrome debugger output the expected result. titleDataAllCryptoUserID has element 3 elements, and each can be read clearly .... all is correct.
    But SingleOrDefault return null, so if I have Debug.Log("myResult =" + myResult ) it logs:
    myResult = , basically empty after the "=" sign.
    it returns sure null 100% sure of this.
    My wallet id is "0x4eba90B4124DA2240C7Cd36A9EEE7Ff9F81Cf601" all I see is 3 EEE. (Why would that be an issue I am curious ... )
    Next time I do a WebGL build I can reproduce the bug but this time I will search for other strings of 42 characters...
    just to see if it has something to do with the content of that string like you suggested....

    At some point I can post a tiny WebGL project on Github for other to test if that thing persist..