Search Unity

WebGL mobile isn't supported because of incompetence

Discussion in 'Web' started by StaffanEk, Jan 24, 2018.

  1. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Unity WebGL for mobiles isn't supported because it doesn't run well enough on mobiles. WebGL doesn't run well enough because Unity doesn't support S3TC and ETC2 compression in WebGL which leads to too much texture memory use for WebGL mobile, which isn't a problem since Unity WebGL isn't suppoted on mobiles, because it doesn't run well enough on mobiles. WebGL doesn't run well enough because Unity doesn't support S3TC and ETC2 compressio.......... etc.

    Why won't Unity just support mobile texture compression and stop bending the truth about the tech not being mature enough. Play Canvas has fixed this in 2016. It's 2018, and Unity still can't fix this.
     
    Last edited: Jan 24, 2018
    be_go, Marks4, JamesArndt and 5 others like this.
  2. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    Well, to be honest it must be more than just texture compression. If I create a single scene with just a cube and a light in it the build will still crash on mobile. Sometimes it will work though, so not entirely sure what's going on. I'd wish that Unity would work on mobile browsers but as it is I have resorted to Cocos Creator.
     
  3. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    It will work on just about any mobile phone if you set the available memory to something like 80 instead of the default 256.
     
    Aiursrage2k likes this.
  4. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    I have previously tried using 64 and it would still randomly crash. Is 80 mb a magic number in this case?
     
  5. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    There's probably differences between phones. I was able to get my somewhat simple game project running WebGL on my Galaxy Note 5. I think the memory was set to 64 or 80. To get it that low I had to optimize my game a bit- namely keeping texture sizes low and crunched, making sure that managed modules are stripped(physics is the big one), and making sure that inactive gameobjects are destroyed instead of turned off.

    Of course there are a whole lot of other issues like audio/video not working.
     
  6. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    That’s weird. I have a simple scene where I only add a cube. That’s all. I don’t know how I could create a simpler scene. I have tried all kinds of player settings to get it to not crash.

    I’ve tried iPhone SE, 6, 6s, 7 and a 10. For Android I’ve tested on Samsung galaxy S6 to 8.

    All the same behavior. Sometimes it runs other times it crashes.

    If you actually got a game running I’d really like to know all your player settings. I feel like I’m missing an important switch.
     
  7. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    I believe webassembly was broken for mobile safari in like 11.2.1 or something, not sure if it has since been fixed. You'll have much more luck trying Android. IIRC our nexus 9 does okay (all things considering) running our content but has a showstopping input bug. Having said all that, I agree having an ETC2 texture option for webgl would be nice. I doubt it will be the game changer though.
     
  8. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Does that cube have a box collider on it? If so, its bringing in the physx engine. If you remove the collider, it should strip the managed physics code out.
     
  9. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I don't know what to tell you I got a fairly complex scene working from iPhone 6 upwards, and on all regular phones aswell.
     
  10. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    About 1 mb was stripped and it actually did seem to make it more stable. So thanks for that tip.
    I could still get it to crash if I reload the browser five or six times but I wouldn't say that's and issue.

    It's too bad that I can't use the build in physics but it's definitely a step in the right direction.

    Thanks again.
     
  11. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    I highly appreciate every discussion about Unitys unsatisfying WebGL support.
    My clients ask for WebGL and I have to look for Sketchfab/Playcanvas programmers.....
    It´s a shame. That simple.
     
    Last edited: Nov 19, 2018
  12. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    If you have to support mobile and your game is 2D only I'd recommend Cocos Creator until Unity starts working on mobile browsers. It's very Unity like in many aspects. I'd much rather work with Unity but I'm forced to do otherwise for now.
     
  13. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    take a look at godot.
     
  14. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    Godot creates too big builds for webgl.

    Last time I looked (v.3 beta) it was 25 mb just for the engine.
     
    MadeFromPolygons likes this.
  15. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    389
    threejs
     
  16. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    Hi guys, its fourth month of 2019!! Any latest progress about unity webgl mobile support?
    I am able to run my webgl build on android chrome. Its some objecs are missing and providing these warning/error/information after loading the player in andriod chrome:

    GLSL: Cannot determine the struct size for 'webgl_ade8414d51e6a184'.
    GLSL: unexpected struct parameter 'webgl_ade8414d51e6a184[1].ÕÀbµÅwebgl_a10910d5196f9b04[0]'.
    blob:http://103.53.44.206/16c4ada7-e063-4fed-81b2-de7d52fee7fa:275 WebGL: INVALID_VALUE: bufferSubData: buffer overflow
    [.WebGL-0xab299400]GL ERROR :GL_INVALID_OPERATION : glDrawArrays: uniform buffers : buffer or buffer range at index 0 not large enough


    WARNING: RGB Compressed DXT1 UNorm format is not supported, decompressing texture
    2UnityLoader.js:4 WARNING: RGBA Compressed DXT5 UNorm format is not supported, decompressing texture
    2UnityLoader.js:4 WARNING: RGB Compressed DXT1 UNorm format is not supported, decompressing texture
    UnityLoader.js:4 WARNING: RGBA Compressed DXT5 UNorm format is not supported, decompressing texture
    UnityLoader.js:4 WARNING: RGB Compressed DXT1 UNorm format is not supported, decompressing texture
    UnityLoader.js:4 Your current multi-scene setup has inconsistent Lighting settings which may lead to different lighting when loading scenes individually or in a different order! Consider homogenizing the following:


    As i am loading asset bundles in the webgl, and when i try to download them it show me the info

    GLSL: unsupported array parameter '[0]'

    I am also getting this warning in console
    WebGL: too many errors, no more errors will be reported to the console for this context

    Do anyone have idea about it? Remember unity clearly says that it don't support mobiles but

    Note that Unity WebGL content is not currently supported on mobile devices. It may still work, especially on high-end devices, but many current devices are not powerful enough and don’t have enough memory to support Unity WebGL content well. For this reason, Unity WebGL shows a warning message when trying to load content on mobile browsers (which can be disabled if needed).
     
  17. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    I am able to run my webgl (with different problem mentioned in above post) in android chrome, using this guide. You first need to enable unity webgl in chrome by going to chrome://flags.
     
  18. Nabeel-Ahmed

    Nabeel-Ahmed

    Joined:
    Nov 1, 2017
    Posts:
    3
  19. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Can someone dumb down for me why WebGL exported from Unity does not run well on mobile devices? What are the root causes for this? I've noticed my PlayCanvas builds run beautifully across just about any device. We're talking complex scenes full of environment geometry. I work for NASA and unfortunately they block the PlayCanvas website so I cannot use the editor on my work workstation. I really need to be able to use Unity to convert these old Flash based games over to WebGL, however we need them to work on mobile too. Are there any improvements planned in regard to mobile support for WebGL?
     
    ina likes this.
  20. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    Too much code really. We strip/minify/compress our wasm binary (code) as much as possible, and it's still like 2.8MB (just code!). That's huge by web standards so it's not something browsers typically handle/optimize for.

    You could put some of the blame on emscripten (what Unity uses to compile it's C++ to wasm/javascript) as that is known to be somewhat verbose in terms of code generation, but honestly I suspect it's more the sheer size of the Unity engine. While Unity has gotten a lot better at "modulization" over the past couple of years (being able to strip physics/physx was a HUGE win for us), I suspect a lot of the code base is still (needlessly?) intertwined. I don't think PlayCanvas does anything fundamentally better than Unity, they just focus on fewer features which leads to significantly smaller code sizes. Depending on your use case, sometimes less really is more. :)
     
    De-Panther likes this.
  21. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    Why does nasa block playcanvas?
     
    JamesArndt likes this.
  22. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    I can, if needed, get it whitelisted but it's blocked as a platform for gaming.
     
  23. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    Eh, so shouldn't Unity services be blocked too? (Platform for gaming)
     
    JamesArndt likes this.
  24. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Someone poke me when it works :)
     
  25. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    I wouldn't know as I don't use any Unity services in projects. The editor itself isn't blocked as the tool is used for lots of non-game related content.
     
  26. DanOrgan

    DanOrgan

    Joined:
    Mar 13, 2018
    Posts:
    6
    It runs well enough on my android smartphone. You know, some hi-end mobile devices are faster then some old computers.
    But I've got some issues with canvas and fullscreen mode.
    Actually, I don't even know how to set the canvas to some fixed resolution. I am writing something like
    Code (JavaScript):
    1. <div id="gameContainer" style="width: 1280px; height: 720px; margin: auto"></div>
    but the canvas on my 1920*1080 smartphone is so big that it can't fit to the screen. It is ridiculous.
     
  27. ZenUnity

    ZenUnity

    Joined:
    Apr 21, 2013
    Posts:
    28
    Any updates on this?
     
    JamesArndt likes this.
  28. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Unity staff could correct me if I'm wrong but I've read no new announcements about major improvements to Unity's webGL performance on mobile devices. Everything I've been reading has been encouraging moving towards Project Tiny for mobile web games. However it's very far from production ready.
     
  29. r8zbeh

    r8zbeh

    Joined:
    Dec 4, 2018
    Posts:
    40
    Hi @DanOrgan did you managed to solve this issue ? if yes what was your approach
     
  30. ewanuno

    ewanuno

    Joined:
    May 11, 2017
    Posts:
    58
    On 2020.1 it no longer displays that message saying webgl isn't unsupported on mobile. My project is really simple, and apart from it being a bit slow on older computers it's working fine apart from a few issues like not being able to disable rotation and giving me errors when I switch to full screen ( even though it works fine when I dismiss the alert
     
    newguy123 likes this.
  31. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    so would a build work on android and ios browsers now with WebGL1 I wonder....
     
  32. ewanuno

    ewanuno

    Joined:
    May 11, 2017
    Posts:
    58
    i'm building for webgl 1 only, hopefully it'll run on a few more phones like that,
    i'm really not pushing the limits with anything though, my games are basically just a few buttons on a ui canvas
     
  33. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547
    WebGL runs great on mobile if you couple it with URP as well. At least on Chrome and Safari. On Firefox it's terribly slow either way.
     
  34. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    The original impression here was that Unity would not be supporting mobile because of not being able to support compressed textures. It is not the question about compressed textures that would be the doorstop for adding support.

    Rather, major reasons Unity does not officially support mobiles are the lack of WebGL 2 support in mobile devices, the difficulty of mobile browsers to compile the amount of WebAssembly code that Unity engine contains, and the WebGL API CPU side validation overhead compared to native GL code.

    If you are following the Tiny Unity project, it is better positioned to support mobile devices, as it has a more WebGL 1 designed renderer and much smaller code footprint. Both classic Unity and Tiny Unity utilize many of the same technology pieces, so we hope that this will give synergy benefits for classic Unity as Tiny Unity is optimized for mobile devices.

    All that being said, we are actively working on and optimizing Unity WebGL builds to make performance better in browsers on both desktop and mobile. Recently we rewrote the whole template code so that loading experience on mobile devices would be more straightforward. Adding mobile texture compression support is on the list, although we do see that the performance issues are generally not due to lack of GPU memory, or GPU bandwidth, but rather, most commonly due to the lack of SRP batching support in URP. This is something that we are also investigating into.

    About the good old PlayCanvas vs Unity conversation: technology products unfortunately come with balances and tradeoffs. I do also wish I could take the best features of each, and none of the downsides of any of them, but unfortunately it is not possible to mix and match. One is better at one thing, the other at something else, and you will have to find which feature set is the best for your use case. Of course feedback is appreciated when you say we are missing your favorite use case :)
     
  35. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Glad to hear work continues on WebGL. Tiny just doesn't feel complete or that it has parity with the Unity development experience for other platforms. I work for NASA and their STEM initiative and Unity is our development tool to deploy web interactives. I did look into Project Tiny but it was just too limited compared to how I was used to working in Unity and what I could work with. Otherwise it would have been a great alternative to WebGL.
     
    Last edited: Oct 6, 2020
    MadeFromPolygons and d1favero like this.
  36. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @jukka_j : WebGL in Unity has improved by leaps and bounds over the last couple of years. Last major project I had to use PlayCanvas, and our current project is entirely Unity WebGL Mobile. There's a lot of performance and memory limitation issues to work around with Unity WebGL still, but good work has been done overall.
     
    JamesArndt likes this.
  37. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547
    There are many things that could be improved on mobile webgl, and it wouldn't even be that much of an effort for you guys. For example, supporting accessing the front and rear camera. WebGL currently only accesses the front camera, I had to make a plugin to be able to access the front and rear camera(and be able to switch between them, etc) on android and iOS devices.

    Same thing with the gyroscope.

    All you have to do is use the webapi....most browsers nowadays support accessing the gyroscope, front and rear cameras, etc. It's really frustrating that the official Unity api that is used to access the hardware on native apps(Input.gyro, etc) don't work on WebGL.

    When you say mobile webgl is not supported, you guys could at least make an effort to use the current web api standards to support hardware access on mobile platforms, the API is there. You just need to use it...I shouldn't need to make plugins for this. It's basic functionality.

    WebGL already runs fine on chrome and safari coupled with URP, even on potato phones. So please just support it already...
     
    Last edited: Oct 6, 2020
  38. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Very good points.

    If you do run into official/built-in Unity APIs that do not work in WebGL on mobile, feel free to submit a bug report preferably with a small test case. While mobile status is not yet official, we do very much appreciate taking in mobile bugs at this time. The surface area of different features in Unity is large, and e.g. your observation about gyro and cameras is a great one that we have simply just not observed in the web team.
     
    MadeFromPolygons and De-Panther like this.
  39. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547
    Jukka, I really appreciate your input and I can see that you care. But these bug reports were already submitted, what I'm saying here is nothing new. You can find people complaining about the things I mentioned on many posts, with a little search =/.
     
  40. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Thanks, I was unaware of that, and have not seen those issues in our Fogbugz database - if they were, they are unfortunately no longer marked as active.

    I am going through the posts to see what kind of issues come up statistically significant, to pick up a picture of the state of things. Hope that I will be able to capture an accurate assessment.
     
  41. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547
    I am going to make some bug reports myself with proposed solutions as well. I could hijack the javascript bindings be able to switch between cameras on Android. iOS is another can of worms though. The javascript bindings on iOS don't even get called, that's why nothing shows.
     
  42. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547
    jukka_j likes this.
  43. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    That's perfect, really well crafted bug reports! Added these to our work queue.
     
    Marks4 likes this.
  44. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    @jukka_j As someone who may have access to this information I would like to ask a quick question. I haven't checked on Project Tiny for quite some time. Has it reached full parity with the WebGL editor experience and deployment capability? Can I use C# in Tiny, use both 2D and 3D, use UI canvas and associated elements, 2D and 3D physics? I suppose I'm trying to see if I should revisit the tech or not to replace our WebGL work. The editor experience, tools and capabilities need to match what we can do with WebGL.
     
  45. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    That may be best to ask in the Tiny forum, though it is developable from the regular Unity editor, and can be deployed from there, although the deployment dialog looks different. You do develop content in C# (the earlier TypeScript prototype has been dropped), and you can do both 2D and 3D. Not 100% sure about the status of UI canvas, I believe that *might* already be there. 2D and 3D physics are possible, although I believe both solutions are more code size conservative versions that do not have all the advanced physics features.
     
    JamesArndt likes this.
  46. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Last I checked @JamesArndt , the biggest issue with ProjectTiny that we have right now is that it doesn't support WebRequests. And they seem to be a long way from implementing them. At least, last time I checked, a month ago or so.
     
    JamesArndt likes this.
  47. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    I believe WebRequest support has already been implemented to Tiny. I reviewed the implementation not that long ago. Not sure if the current/latest Release has it shipped yet, but if not, the next one should.
     
  48. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    598
    Last edited: Oct 8, 2020
  49. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Thanks for bringing that issue to my attention, have not seen that before in our bug database, and we do not have any changes to that in trunk code. Added it to our work list.
     
    MadeFromPolygons and roka like this.
  50. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    Is there a big change in performance(or memory usage or anything else) between 2019.4.X and 2020.2 ? Trying to guage if it is worth updating our app to latest version and could not tell from the discussion
     
    ROBYER1, ScottAdams and JuanMaldonado like this.