Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Whats the issue with WebGL on mobile when Unity Forma clearly shows it's possible?

Discussion in '2021.2 Beta' started by Bersaelor, Jun 15, 2021.

  1. Bersaelor

    Bersaelor

    Joined:
    Oct 8, 2016
    Posts:
    111
    So, today I tried the latest Alpha build of Unity 2021 (alpha 20), and saw that the WebGL builds still only work on desktop browsers (our minimal performance test app ).
    On Mobile the page doesn't even finish loading.

    Now Unity is also promoting Unity Forma , apparently a no-code platform for digital marketing of products using 3D. And the unity forma WebGL builds clearly work on mobile: https://forma.dl.it.unity3d.com .

    Will we ever be able to use WebGL on mobile browsers using the default Unity system?
     
  2. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    Unity Forma is built on top of normal Unity. There is no magic under the hood, it is using the normal Unity WebGL export.

    The Forma example might be not that great, since it just a single model being shown and not much else going on.

    While we are not supporting mobile for WebGL yet we are making efforts to improve there if you take a look at the roadmap https://resources.unity.com/unity-engine-roadmap/platforms
    We are aiming only at highend devices, so your milage my vary.
     
  3. Bersaelor

    Bersaelor

    Joined:
    Oct 8, 2016
    Posts:
    111
    Thank you for the quick reply!

    I feel like the forma example model has less geometry then our test scene but maybe I am wrong, it feels like the Forma example loads much faster too. Are there any WebGL special export setting that are not common knowledge that were used in Forma?
     
  4. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    There are none that are hidden in any way. It is just optimizing heavily in content and being very strict in what you add. For just a viewer you can disable a lot of stuff you don't need but the general advice still is the same:
    • Brotli compression (inlcuding proper server setup)
    • disable all exceptions (make sure you project won't throw any)
    • diligent engine code stripping (you can force disable features you don't need to not add them by accident
    • optimize assets, shader variants etc to only include what you really need
    • use a "loader" scene and addressables for a fast initial load
    For 21.2 we have several features for better mobile support (should all be in the upcoming beta release)
    • upgrade to emscripten 2.x
    • compressed audio support
    • compressed mobile texture formats support
    • new incremental build pipeline for faster iteration
    • mobile gyro and accelerometer support
    • and some smaller bits + bug fixes
    Hope that helps a bit. And maybe we should work on better docs and guides for developers going forward. But broadly speaking all the guides concerning optimzation for mobile projects apply to WebGL too
     
    mgear, Bersaelor and tonialatalo like this.
  5. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    We are about to ship an application using WebGL and altough it required some tinkerking we got it to run property on both desktop and mobile browsers. The only unsolvable issue we found is that on iOS we require iOS version 14.0 and up.
     
  6. ybtre7892

    ybtre7892

    Joined:
    Nov 8, 2022
    Posts:
    2

    Could you provide some extra information on how you got it working well on both? It would be very helpful to anyone coming across this thread in the future, including myself :)
     
  7. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Well actually we didn't. We hit a hard limit - the mobile browser sets an arbitrary amount of memory available for the wasm application which was not deterministic. This caused our app to crash randomly - sometimes the same device would get more or less memory, and we could not make this behavior predictable across multiple devices. Since our unity app was basically a plugin, we ended up using mobile builds and embedding them inside the native iOS and Android applications. On the desktop browsers we did not have issues
     
  8. ybtre7892

    ybtre7892

    Joined:
    Nov 8, 2022
    Posts:
    2

    ah damn, sorry to hear it didnt work out. Is there a script/command I could use to detect ow much memory the wasm application provides at runtime? Even if its non-deterministic it might work for my use case because we're aiming at a very small project to deploy to web (and support mobile browsers)
     
  9. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    I believe we were not able to determine that.
     
    ybtre7892 likes this.