Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Do WebGL games work on mobile phones?

Discussion in 'General Discussion' started by venom789, May 18, 2022.

  1. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    I seem to have seen that it was possible, yet I have tried everything and nothing works.

    2021.3.2f1
     
    makaka-org likes this.
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you have the URL to your game? So it works on a PC/Mac, but not a mobile browser?
     
  3. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,083
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,553
    venom789 and stain2319 like this.
  6. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    With Powershell : python -m http.serveur
    j'ai :
    Code (Boo):
    1. Serving HTTP on :: port 8000 (http://[::]:8000/) ...
    2. "GET / HTTP/1.1" 304 -
    3. code 404, message File not found
    4. "GET /Build/test8.data.gz HTTP/1.1" 404 -
    5.  
    On explorer (http://localhost:8000/) :
    Code (Boo):
    1. Unable to parse Build/test8.framework.js.gz! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: gzip" present. Check browser Console and Devtools Network tab to debug.

    Murgilod I am on 2021.3.2f1 .


    My phone for the test: iphone 12 pro max.

    On itch.io, my project only partially worked once, then it stopped working.

    I just recreated a new project, I cleaned up as much as possible, I removed the mobile controls, to see if that wasn't what was causing the conflict, but still no display. If I understand the error message correctly, I must have made a bad setting.

    https://play.unity.com/mg/other/exportwebgl-1
     
    Last edited: May 18, 2022
    AlexeiAnd likes this.
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So you would want to get it working locally first, then deploy. Just do Build and Run from the Unity Editor, that will start a local webserver and open your project in a browser. Does that work?
     
  8. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    yes, Build and Run works.


    I made a translation error with a youtube video, I thought it was a solution to set up mobile webGL.

    Which explains why I went on a local test, but it's just my lack of knowledge.
     
    Last edited: May 18, 2022
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Great! Next step is to publish to a remote web server, and get it working from a browser on your PC
     
  10. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    My English isn't perfect, but I guess that's irony ^^

    I've been sleeping very little lately ^^

    If I understood correctly, opening a WebGL project is possible with a mobile.

    I am aware of the aesthetic problems that this can cause.

    To avoid wasting too much time, do you know of any documentation that explains how to set up this type of project ?
     
  11. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,553
    I believe you might need a proper http server. Or something more advanced than python http.server module. Because if you use python's http.server webgl project webpages can fail to load.
     
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    If it doesn't work on your PC from your web server, it won't work on mobile either. It's just a bit easier to test from your PC browser instead of a mobile browser.
     
  13. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    néginfini For the python http.server module, I solved the problem by checking "Fallback decompression".

    What are you thinking about?

    JeffDUnity3D
    If I understood correctly, to continue the tests, you ask me to either :
    • Turn one of my pc into a web server.
    • Either host and configure my WebGL build on a remote server.

    That's right ? I apologize if I ask you the question, but my English is not perfect :/
     
  14. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    I got this error code on the project hosted on itch, with my phone :

    Code (Boo):
    1. RuntimeError: Out of bounds memory access (evaluating '(_main=Module["_main"]=Module["asm"]["Kg"]).apply(null,arguments)')
    2. <?>.wasm-function[427]@[wasm code]
    3. <?>.wasm-function[1551]@[wasm code]
    4. <?>.wasm-function[9786]@[wasm code]
    5. <?>.wasm-function[16514]@[wasm code]
    6. <?>.wasm-function[16530]@[wasm code]
    7. <?>.wasm-function[16466]@[wasm code]
    8. <?>.wasm-function[35275]@[wasm code]
    9. <?>.wasm-function[16566]@[wasm code]
    10. <?>.wasm-function[6346]@[wasm code]
    11. <?>.wasm-function[6345]@[wasm code]
    12. <?>.wasm-function[30635]@[wasm code]
    13. <?>.wasm-function[14258]@[wasm code]
    14. <?>.wasm-function[14257]@[wasm code]
    15. <?>.wasm-function[26663]@[wasm code]
    16. wasm-stub@[native code]
    17. @blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:296996
    18. callMain@blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:362051
    19. doRun@blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:362606
    20. run@blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:362775
    21. runCaller@blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:361700
    22. removeRunDependency@blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:15982
    23. @blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:1967
    24. doCallback@blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:90173
    25. done@blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:90329
    26. @blob:https://v6p9d9t4.ssl.hwcdn.net/7a1801de-2ecc-43f9-9a07-c01872449df6:3:83432
     
  15. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @venom789 What is the URL? Does it work when using your PC browser? If it doesn't work on your PC browser, it won't work on your mobile browser either.
     
  16. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,627
    If you want Webgl to work on mobile use a different engine.

    Every time I tried Unity it worked like ass, or “it might work” as per the docs.
     
  17. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    Sorry, yes it works on my pc browser

    See the link :
    https://venom06660.itch.io/test3

    AcidArrow
    Indeed I never had this kind of problem on construct, on the other hand in my research, I could note that Ureal had similar problems.

    It is normal that large engines have more problems given their complexity.

    But if it's too complicated to solve, I don't see the point of making you waste too much time on it.

    I had in mind a small project on the web, but this is not absolute, and I could very well find alternative solutions :)
     
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,627
    I guess we need Unity to become a small engine again then.
     
  19. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,553
    Yes, the issue is with decompression.

    Last time I wrote a webgl unity application was one year ago, and I forgot what I was using. It was not python http server, however because of decompression issues. I think initially I used some small standalone windows application for the server, and then switching to uploading the files to a remote server.
     
  20. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    Thank you néginfini,
    as AcidArrow says, there are other effective solutions for WebGL (construct, playcanvas ...), I have already lost a whole day looking for it, it's exactly the time I would have spent on another engine to create a prototype and put it online.
    I'm a graphic designer, so at the programming level it doesn't bother me too much, but configuring the software of your server so that it adapts to your project... I have neither the knowledge nor the desire to do it.

    Personally I would like to have an answer like this :
    for our site play.unity.com, you needed to create your project on
    • such version of Unity,
    • with these settings,
    • this pipeline,
    • ...
    But I think it goes against the internal policy to do the promotion of obsolete version, for an abandoned platform.

    Personally, between the fact that smartphones finally have the necessary capacity to use WebGL effectively, and the major security flaws in the software installed on the phones, I think it's the right time to develop this technology.

    If that's not unity's opinion, I respect it, accept what you can't change.

    What I have trouble understanding is why this is hard to implement, if not impossible, on their own play.unity.com site, although they used their own WebGl Publisher export software, on their own server, at the limit we add a small "mobile version" box to check and the export software checks the project, which informs the user of mobile-oriented optimization defaults.

    So yes it's frustrating, but it doesn't matter, I don't use Unity specifically for the WEB, like everything this engine has defaults and qualities.

    I'm not going to waste any more time on it, and even if the learning curve for each engine is high, I'm not going to limit myself to using just 1. Even if it would be simpler, but i also understand that in this world nothing is simple ;)
     
    Last edited: May 19, 2022
  21. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,246
    Probably need project Tiny back with good web support, until then webgl is a heavy weight thing.
    But I wonder if webgl is or will be a success anyway - Unity or not - a 3d window in a browser just doesn't compare to native on a mobile platform and on desktop there are issues over wrong GPU (if 2 available) being used and memory limits. On Mac, safari complains about energy usage!
    Seems like no one wants powerful interactive content on web - 3d or 2d. Must be low energy, small size.
     
  22. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,950
    Outside of developers almost no one truly cares about security. What they do care about are battery life and application performance neither of which you're going to get by running an app inside of another app.

    Also what led you to believe browsers are any more secure than applications? Remember they're apps too.
     
  23. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    For what its worth that link runs on an older low end android phone I tested with.
     
    Ryiah likes this.
  24. GimmyDev

    GimmyDev

    Joined:
    Oct 9, 2021
    Posts:
    160
    From what I understand, apple is sabotaging that work around their close garden, because the web is free, they had to cripple it on their hardware. Imagine having efficient apps not on appstore only!

    /conspiracy theory
     
    andyz and adamgolden like this.
  25. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    I've basically said the same thing - anti-competitive practices are real. It's not a theory, just look at memory consumption limitations of a mobile web browser vs. an app. Who's responsible? It's as simple as that.
     
  26. GimmyDev

    GimmyDev

    Joined:
    Oct 9, 2021
    Posts:
    160
    On the other side, constraint makes art, we just need someone to figure out the aesthetics format with a big accidental success (look at how flappy bird created the whole hyper casual genre, with minimalist aesthetics).

    After all regular website are still needing some resource to run all that messy javascript modern web can't get enough of. And Apple need those regular website to still display correctly. I hope.
     
  27. plusplusgames

    plusplusgames

    Joined:
    Jul 26, 2021
    Posts:
    64

    I normally use gamepipe.io it has basically 0 rules on what games are allowed and what versions, they are clear that they wont steal your game so I think its the best choice for game hosting
     
  28. venom789

    venom789

    Joined:
    Apr 18, 2022
    Posts:
    178
    Sorry for my late reply, I was on vacation.

    Ryia, logic made me think it was easier to secure a single app like a web browser, rather than a bunch of small independent apps, but you might be right, attacks are mostly against browsers , and so even though it makes sense to me, I'm wrong.

    lmbarns Thanks interesting ^^ but not on latest iphones devices :(

    Controversy, GimmyDev, I think you were right.

    plusplusgames I will test, but I think the result will be the same.
     
    Last edited: Jun 6, 2022
  29. AlexeiAnd

    AlexeiAnd

    Joined:
    Mar 6, 2023
    Posts:
    1

    That's it! This works.... kinda.
    I had to do:
    python -m http.server
    (slightly different spelling)
    Now I was able to go to http://<my_local_ip_address>:8000/ on my mobile and it opened the right page. But then it failed with some kind of very weird Unity error. Basically Unity player couldn't be loaded. My game is very very simple. So I think as others said above, you can't open a Unity WebGL app on a mobile browser.
     
  30. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,003
    I tested Mobile WebGL with Unity 2022.3.7, iPhone XS Max, Samsung Galaxy A71. It works.

    New Input System declares here that sensor (accelerometer, gyro, etc.) support for WebGL on Android and iOS devices is available in Unity 2021.2.

    So it works, and I recorded a video tutorial about building and testing for Mobile WebGL.

    > Complete Article with all Links and Commands <

     
    sonictimm likes this.