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

Question Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js ERROR

Discussion in 'WebGL' started by nintendaii, Sep 29, 2023.

  1. nintendaii

    nintendaii

    Joined:
    Dec 16, 2019
    Posts:
    13
    I am trying to build my project for WebGL and getting this error:
    Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
    wasm-ld: error: function signature mismatch: DownloadFile
    >>> defined as (i32, i32, i32, i32) -> i32 in D:/UnityProjects/<ProjectName>/Library/Bee/artifacts/WebGL/il2cppOutput/build/GameAssembly.a(l0ktezpoldnh.o)
    >>> defined as (i32, i32, i32, i32, i32) -> void in D:/UnityProjects/<ProjectName>/Library/Bee/artifacts/WebGL/il2cppOutput/build/GameAssembly.a(rvr59hijrpak.o)

    I have this error only on windows 11, tried on windows 10 - works fine. Also, on Windows 11 the build is succesful when I set Enable Exception to Full With Stacktrace. But I need Excplicitly Thrown Exceptions Only
    Tried to delete Library folder and the Bee folder - didnt helped. Any thoughts how to fix it?
    OS: Windows 11
    Unity Editor: 2022.3.4f1
     
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    This reads like maybe your project has two different implementations of that function?

    I searched through the Unity codebase for "DownloadFile", and I was not able to find references to such a function coming from Unity's code. The file GameAssembly.a should contain all the project C# and C++ code. Is there maybe a native plugin in the project that would implement such a function? Can you find references to that function in your project's source tree?
     
  3. nintendaii

    nintendaii

    Joined:
    Dec 16, 2019
    Posts:
    13
    Hey, sorry for late reply. Yes, I have a plugin for webgl called StandaloneFileBrowser. Here is the function
    Code (JavaScript):
    1. DownloadFile: function(gameObjectNamePtr, filenamePtr, byteArray, byteArraySize) {
    2.         try {
    3.  
    4.             gameObjectName = UTF8ToString(gameObjectNamePtr);
    5.             filename = UTF8ToString(filenamePtr);
    6.             var contentType = 'application/octet-stream';
    7.  
    8.             var bytes = new Uint8Array(byteArraySize);
    9.             for (var i = 0; i < byteArraySize; i++)
    10.             {
    11.                bytes[i] = HEAPU8[byteArray + i];
    12.             }
    13.  
    14.             var downloader = window.document.createElement('a');
    15.             downloader.setAttribute('id', gameObjectName);
    16.             downloader.href = window.URL.createObjectURL(new Blob([bytes], {
    17.                 type: contentType
    18.             }));
    19.  
    20.             downloader.download = filename;
    21.             document.body.appendChild(downloader);
    22.             document.onmouseup = null;
    23.             downloader.click();
    24.             document.body.removeChild(downloader);
    25.  
    26.             var returnFilePath = filename;
    27.             var bufferSize = lengthBytesUTF8(returnFilePath) + 1;
    28.             var buffer = _malloc(bufferSize);
    29.             stringToUTF8(returnFilePath, buffer, bufferSize);
    30.             return buffer;
    31.  
    32.         } catch (err) {
    33.             var returnError = "Error. ";
    34.             returnError.concat(err.message);
    35.             var bufferSize = lengthBytesUTF8(returnError) + 1;
    36.             var buffer = _malloc(bufferSize);
    37.             stringToUTF8(returnError, buffer, bufferSize);
    38.  
    39.             console.log(returnError);
    40.  
    41.             return buffer;
    42.         }
    43.     }
    I didnt found any other implementations of this function (only the one in .jslib file). I am wondering why it is working on Windows 10 but NOT in Windows 11
     
  4. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    Searching the plugin code for declarations of DownloadFile, I can find the following:

    https://github.com/search?q=repo:gkngkc/UnityStandaloneFileBrowser downloadfile&type=code

    It looks like the .jslib file that you have is out of date? Looking at

    https://github.com/gkngkc/UnityStan...owser/Plugins/StandaloneFileBrowser.jslib#L64

    the code has changed to

    Code (JavaScript):
    1. DownloadFile: function(gameObjectNamePtr, methodNamePtr, filenamePtr, byteArray, byteArraySize) {
    instead.

    It looks like that change occurred in this commit: https://github.com/gkngkc/UnityStan...8343f9df618cc1da8217f8ee0827613478d82605d3R70

    previously the function took four parameters like you have, but now the function takes five parameters, including a new "methodNamePtr" field as the second parameter.

    The Windows 10 vs Windows 11 operating system difference is likely a red herring here. It is more likely that there is a compiled object file or .cs file mismatch in the code deployments on these two PCs. There is maybe an old version of the plugin on one of the PCs, and a newer version of the plugin on the other, and that results in the mismatch. Or maybe somehow a combination of new and old plugin files got mixed up on the PC.

    Looking at the latest plugin code around DownloadFile at https://github.com/search?q=repo:gkngkc/UnityStandaloneFileBrowser downloadfile&type=code

    seems correct: the implementation takes in five parameters, and the two occurrences of a declaration to that function also all take five parameters, so they all match.

    Try to double check that you have a good latest version of the plugin with all the newest files, and then do a clean of all intermediate object files in the project. That should do the trick.
     
  5. nintendaii

    nintendaii

    Joined:
    Dec 16, 2019
    Posts:
    13
    Thanks, will do that. Also, any idea why it makes the build with Enable Exception-> Full With Stacktrace and does not with Enable Exception-> Excplicitly Thrown Exceptions Only?
     
  6. nintendaii

    nintendaii

    Joined:
    Dec 16, 2019
    Posts:
    13
    I double checked the plugin code on both Windows 10 and Windows 11 machines - they are identical. I don’t know how it is possible that on Windows 11 it is looking for updated plugin signature in this line
    >>> defined as (i32, i32, i32, i32, i32) -> void in D:/UnityProjects/<ProjectName>/Library/Bee/artifacts/WebGL/il2cppOutput/build/GameAssembly.a(rvr59hijrpak.o)
    For now, I will try to fix this without updating to new version of plugin (it is a pain right now to change all the places where I am calling the DownloadFile function). Just want to understand why this is happening
     
  7. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    Have you tried to use the dropdown menu for Clean Build... ? Maybe that could help if there is something left stale in the project.

    upload_2023-10-3_16-24-19.png
     
  8. nintendaii

    nintendaii

    Joined:
    Dec 16, 2019
    Posts:
    13
    Yes, I tried. No luck (
     
  9. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    Is the project something you can share? Or something that you can strip down to a minimal test case and share?
     
  10. nintendaii

    nintendaii

    Joined:
    Dec 16, 2019
    Posts:
    13
    Unfortunately, no. I think I will try to update the StandaloneFileBrowser plugin