Search Unity

Test your WebGL content on Facebook with Unity's new Facebook build target

Discussion in 'Web' started by jonas-echterhoff, Nov 17, 2016.

  1. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    As announced here , Unity 5.6 will add a new Facebook build target, which allows you to integrate Facebook into your builds (both WebGL and Gameroom), and upload your games to Facebook straight from the Unity Editor.

    You can test this functionality based on a Unity 5.5 beta build available here: https://developers.facebook.com/docs/games/gameroom

    We would love to get some feedback from WebGL developers on this functionality. If you are interested, please give it a spin, and share your experiences in this thread.
     
    Thaina likes this.
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Kind of hard to even consider this as a platform when their limit size for a game is 50mb compressed.
     
  3. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    I don't think that is a requirement. It is listed as "best practice" on the page, which surprises me, because many of the games currently on Gameroom are much bigger then that.
     
    Meltdown likes this.
  4. kthai

    kthai

    Official Facebook Employee

    Joined:
    Dec 17, 2015
    Posts:
    1
    The 50 MB limit is inaccurate in the documentation, it has been removed to avoid further confusion.
     
    ilmario and Meltdown like this.
  5. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    That's great news.
    Is there a limit in place at all then?
     
  6. OldUnityFool

    OldUnityFool

    Joined:
    Feb 27, 2015
    Posts:
    25
    The german version of the page:

    https://developers.facebook.com/docs/games/gameroom/launch


    shows me this content:


    Launch deines Spiels in Gameroom

    Wenn du dein Spiel entwickelt und getestet hast, kannst du es in Facebook Gameroom veröffentlichen.

    1. Hosten deines Spiels auf Facebook
    2. Zahlungen
    3. App-Anzeige
    4. Landing Page
    5. Öffentlicher Launch
    Hosten deines Spiels auf Facebook
    Anforderungen zum Hosting
    Facebook bietet unter folgenden Voraussetzungen kostenloses Hosting für Spiele an:

    • Die Gesamtgröße einer einzelnen hochgeladenen ZIP-Datei darf höchstens 200 MB betragen.
    • In Einzelfällen hosten wir eventuell bis zu 500 MB.
    Weitere Informationen zum Hosting durch Facebook findest du in der Dokumentation.

    But in the english version i don´t see "hosting"

    It ´s a liitle bit confusing!
    So let´s hope it´s because everything is new.
    May be we get 500MB;):p
     
    Last edited: Nov 19, 2016
    Meltdown likes this.
  7. OldUnityFool

    OldUnityFool

    Joined:
    Feb 27, 2015
    Posts:
    25
    Currently i am testing Unity 5.5.0b9 for Facebook.
    I can create, uploade und play if i use in the Build-settings: Facebook -> Gameroom(Windows).
    But when i use Facebook -> webgl : i can create and upload to Facebook but then i can´t start the game.
    Questions:
    Should the game normaly start in a browser(Firefox) or in the Facebook Gameroom-App ?
    Where can i find the settings for webgl, if the game is hosted on Facebook?
     
  8. OldUnityFool

    OldUnityFool

    Joined:
    Feb 27, 2015
    Posts:
    25
    As mentioned in my post above, I can create a Webgl-Build and upload to Facebook but if start the game, i get this error:

    WebGlError.png

    I´m shure is my fault. Can somebody give me an hint? Thanks
     
  9. getreadyio

    getreadyio

    Joined:
    Jan 5, 2017
    Posts:
    5
    I'm trying to understand whether this user story is possible.... "I want to play this game inside Facebook on my iPhone." Meaning, run a webgl blob inside the user's news feed (not the game room "Instant Games" on Facebook mobile). The use case is the ability to share mini games and have them appear as playable units directly in the wall in the mobile app. Specifically, we have people making mini games in unity playing in webgl, and they would like to "post my game to my Facebook" and have their pals play it instantly inside the feed (no horizontal shift to a game download in another section of Facebook). Specifically, look at this page: getready.io/arcade. Each of these projects is a Webgl container made in unity that's embeddable on any site- you can embed them in Facebook but the deep link re-routes to our an app download to play- in this version it would play instantly inside Facebook as webgl. So this blob would go into Facebook if we submitted our "player" to Facebook. But we can't figure out if the current version supports this type of use case. Can anyone explain, or better yet, point to an existing Facebook Page that plays webgl content inside the feed. That would be super helpful to see. Thank you!
     
    Gotama likes this.
  10. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    This is currently not really possible. As mentioned in the manual we don't support mobile at the moment for our WebGL export.
    You might be able to make your content run on some high end devices but on average handhelds it will probably not run. Sorry.
     
  11. dianadorinamita

    dianadorinamita

    Joined:
    Jan 21, 2016
    Posts:
    25
    i publish 4 games recently on facebook and it past 2 months and not see players on my game, please help
     
  12. waltran

    waltran

    Joined:
    Feb 23, 2017
    Posts:
    36
    While the game perfectly shows up and plays on apps.facebok.com built with webgl and hosted on facebook it doesn't show up in gameroom. only one time it did show up and i was able to play which was even faster than web browser. now i don't know why it doesn't show up on gameroom. there is only settings about gameroom "native" on developers.facebook.com but we target webgl only.
    edit: i'm also able to play the game on gameroom via "downloaded games" tab...
    can anyone help me or show me an "updated and complete" guide about gameroom webgl publishing.
    edit2: now it started showing up in gameroom. i gues for some supernatural reasons.
     
    Last edited: May 25, 2017
    Meltdown likes this.
  13. cmai

    cmai

    Joined:
    Jan 11, 2017
    Posts:
    2
    I'm trying to upload a build I made using the Facebook target to my Facebook Dev Portal, but I keep getting this "Error (try uploading again)" with no explanation on what the error is. Has anyone else come across this error or has some insight on what it could be? I've tried uploading manually as well as through the Unity Editor but it doesn't seem to matter.

    Thanks,

    Chris
     

    Attached Files:

  14. ghost99

    ghost99

    Joined:
    Jul 12, 2013
    Posts:
    6
    Yeah, I've run into this problem...quite awhile ago and did resolve it. So from distant memory, this is what happend and how I fixed it. I manually created a zip file to upload to facebook. It was somewhat large so it takes a long time to load. After the long load time I got
    "Error (try uploading again)"

    In short, it was a file format problem :
    1. Not a zip file
    2. Zip file contained wrong/missing build files

    This was for a WebGL build and that's where I've asked for help (from Unity) and haven't got any help yet :
    * Facebook WebGL Unity game takes 40 - 60 seconds to load just for a splash image and 'play' button
    * Unity best practices for reducing load times doesn't seem to work on Facebook
    * Unity Bundles must be included in the zip file
    * Unity can't find files on facebook 'tab' pages (a work around for CORS)
    * Does Unity 'appdata' work on Facebook?
    * How do you find the FB appdata dir name?
    * Unity streamed data must be in zip file
    * Can't stream data/bundles on cross-domain URL's due to CORS restrictions

    No body is really going to play my games deployed on Facebook because the load times are way too long.

    BTW, I hope that my reply helps you fix your problem
     
  15. ghost99

    ghost99

    Joined:
    Jul 12, 2013
    Posts:
    6
    I tried facebook native gameroom build/hosting for my WebGL build/hosting on facebook using Unity 2017.1. The native gameroom features should solve a bunch of the WebGL limitations but...the unity built-in 'upload build' doesn't work for me either. I get the above mentioned error : 'Error (try uploading again)'

    * It did 'scan' my local files
    * It did begin and upload about 4Mb of 40Mb of uncompressed files
    * Not sure if it tried to upload compressed or uncompressed files

    I was able to uncompress the 7zip created by the Unity build and upload that manually to facebook (about 49 files). Facebook initially reports a file size of about 40mb then does some 'processing' after which the file size is reported as about 10mb.

    I was able to discover the game via facebook gameroom but it didn't run (got a URL error). I was able to discover and run a local unity build via a gameroom 'debug' mode. The load time was faster (by about 1/2). If I can load the game, it runs and works as expected without errors.

    I can no longer discover the game via gameroom and can't load and run it.

    I can still see the debug local build for debugging via a gameroom menu and debugging button.

    My goal is to have a platform for players to discover my game and play it. I still have hope that facebook will be one of those platforms.
     
  16. ghost99

    ghost99

    Joined:
    Jul 12, 2013
    Posts:
    6
    This is the error message detail for Unity 2017.1, using 'built-in' facebook SDK 7.9.4 for 1 unity scene with default main cam and dir light. Project has only facebook SDK settings and 1 168K texture; using 'build for fb upload'. Facebook AppId and upload token added to build/player settings. This is for native gameroom build.

    Uploading build to Facebook failed: stdout:
    Uploading C:/Unity2017\SplashNPlayScn1-v1.7z to https://graph-video.facebook.com/1510326922381419/assets
    stderr:
    WebException error: System.Net.WebException: The request was aborted: The request was canceled.
    at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
    at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
    at Uploader.HttpUploadFile(String url, String artifactsUrl, String paramName, String contentType, NameValueCollection nvc)
    at Uploader.Main(String[] args) ResponseUri = <null>

    System.Threading.RegisteredWaitHandle:DoCallBack(Object)
     
  17. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    387
    Same issue ...
     
  18. jura_z

    jura_z

    Unity Technologies

    Joined:
    Oct 10, 2016
    Posts:
    27
    `System.Net.WebException: The request was aborted: The request was canceled`:
    We're looking into this, should be fixed soon from FB side. And new uploader implementation almost ready, that also will help avoid such situations.

    @ghost99:
    >Unity best practices for reducing load times doesn't seem to work on Facebook
    Actually, should work. Also, you can try to build webgl build and check build report -> stripping (files.unity3d.com/build-report/) for anything that makes your build big and remove that (like 3d physics if you don't need that)

    >Unity Bundles must be included in the zip file
    Well, if you want to include them then yes. But another option is to use your backend with https + setup CORS there

    >Unity can't find files on facebook 'tab' pages (a work around for CORS)
    what's tab pages? can you elaborate please?

    >Does Unity 'appdata' work on Facebook?
    What's appdata exactly?

    >Unity streamed data must be in zip file
    Is it a question?
     
  19. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    @jonas-echterhoff

    I think you guys are doing a great job as I just managed to get Chasmic Rush up and running in Facebook using WebGL using 2017.1. Note that FYI 2017.2 WebGL is broken.

    The game looks nearly identical to the iPhone version, though I did have to remove the blur optimised as the strain would be too much for the browser.

    I wrote about my experience on my blog where unfortunately integrating with Facebook became really painful, so I do think there is some way to go.

    I do have ideas on how to fix this though....
     
  20. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Hey jonas-echterhoff, others,

    Having some difficulty integrating my WebGL game into Facebook.

    I'm having issues I assume are due to iframe sandboxing (not sure), but seems my parameter passing between Unity <-> HTML/JS won't work in the Facebook iframe..

    Trying the exact same setup using vanilla WebGL and my own web server works without issue, but as soon as I attempt the same in the Facebook iframe, things fall apart.

    This post here: https://forum.unity.com/threads/web...nd-gameinstance-sendmessage-dont-work.500816/ covers most of the details.

    I could really do with some assistance here, I've been trying/testing/researching for over a day now with very little success.

    Any ideas?
     
  21. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    What is the need to pass parameters between Unity <> HTML/JS ?

    Chances are Facebook is crippling it due to permissions or something.

    I have a simple AppStore button in my game to link to the AppStore URL for the mobile game, but that does not work :(
     
  22. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I'm invoking some 3rd party JS to show reward videos (over the iframe).

    Unity -> HTML/JS, required to invoke the "ShowVideo()" on the third party JS sitting in the iframe
    HTML/JS ->Unity, required to notify the results of watching the video (worked|failed|skipped|etc)

    Yep I'm pretty sure that's the case (iframe sandbox params), but there are other games out there that have got it to work.

    Given that Unity have some alliance with Facebook, I'd have thought they'd have intimate knowledge of how to get this done, it'd be fantastic to hear from Unity on this, since I'm out of ideas and it's now endangering the release of our product.

    I've not looked into this yet (but will want to do the same) so please keep us posed on any success you have there!
     
  23. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    One of the things I'd like to see is some proper support from Facebook, as I said in this post here :

    http://chasmicgames.com/unity-3d/unity-webgl-facebook-angry/

    My suggestion is that if Facebook are serious about getting more Unity games on the platform they need to invest in creating a proper plugin that does the heavy lifting once to reduce the integration burden for each developer. Moreover, a proper up to date sample game (using WebGL) that runs across multiple platforms showing how they integrate would go a long way to moving things in the right direction.
     
    larku likes this.
  24. nfmelendez

    nfmelendez

    Joined:
    Feb 26, 2015
    Posts:
    22
    Hi you can get some ideas of our magic and empire game, really i can't find a webgl game more complex than this one to share knowledge: https://apps.facebook.com/magicandempire

    Also is coming to facebook gameroom via a PC version under this facebook "steam"
     
    ilmario likes this.
  25. GarrettCMiller

    GarrettCMiller

    Joined:
    Jan 20, 2013
    Posts:
    30
    I, too, am having unbelievable difficulty getting even a simple, empty test application to upload and work on Facebook hosting with WebGL. I have followed the step-by-step from both Unity and Facebook and still nothing but a blank frame. Nothing loads except the Facebook header and sidebar.

    I am getting the same

    "Uploading build to Facebook failed: stdout:
    Uploading C:/[...].7z to https://graph-video.facebook.com/[...]/assets"


    error that others are, just trying to upload inside Unity. So instead I have uploaded successfully from the Facebook app dashboard. I went through several times and made sure that the options are exactly as instructed in the tutorials, but still nothing works. I have tried two completely different apps and different builds and nothing even loads.

    Like puzzlekings said in his blog post (which I agree with 100%), the documentation for this from both Unity and Facebook is almost non-existent and what is there is not helping me in any way whatsoever. This process is definitely the most difficult thing I've tried to do in my 6 years of Unity experience, and there is NO reason that it should be. I have spent over 3 days trying to get ANYTHING to appear on-screen and nothing. Facebook seems like the perfect platform for creating awareness of your game, but I'm starting to think I'm just wasting my time. :(
     
    ilmario likes this.
  26. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Hang in there you'll get it working.

    Which version of Unity? It's working fine with 5.6.2p2 for myself)

    Are you uploading the 7z that unity creates?

    Ensure your memory settings are not too high (I'm having success with 512mb)

    Use the default unity WebGL template (just to eliminate any issues there).

    If you're using chrome, hit F12 and inspect the console, there may be hints there.
     
  27. GarrettCMiller

    GarrettCMiller

    Joined:
    Jan 20, 2013
    Posts:
    30
    I'm using Unity 2017.2.0f3.

    I literally created a blank new project, imported the newest Facebook SDK version (also tried the built-in one at first, same result however), switched platform to FB, put my AppID in the settings, dragged the FB SDK examples scenes into the scene build list (exactly as shown in FB's tutorial), saved, and successfully built a 7z. Uploaded that via the app control panel, marked it for production and opened the page. I get the header and sidebar, but nothing else.

    I opened and looked at the console. Nothing.
     
  28. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Very Odd - did you want to add me as a tester (PM me) and I'll take a squiz to see if I can spot anything?

    Also, did you test the app in the editor? Facebook SDK has stubbed mock implementation for rudimentary Editor testing.

    Add some test users here: https://developers.facebook.com/apps/{your app id}/roles/test-users/ (replace {your app id} as appropriate. then click the edit button next to the test user's name and get an access token for the user - FB Editor mock implementation will want the access token to log you in.
     
  29. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    @GarrettCMiller

    In your facebook developer console are your "Facebook Web Games" settings as follows:

    Legacy Unity Integration: NO
    WebGL: YES
    Simple Application Hosting: YES
    Unity Web Player Install Flow: NO
    Override WebGL Unsupported Experience: NO
     
  30. GarrettCMiller

    GarrettCMiller

    Joined:
    Jan 20, 2013
    Posts:
    30
    I tried it in the editor and it seemed to run just fine. And yes, those are the Facebook Web Games settings I have. I can add you as a tester to see if you can see anything. I know other people I've tried though have seen exactly what I see, the mostly blank page.
     
  31. GarrettCMiller

    GarrettCMiller

    Joined:
    Jan 20, 2013
    Posts:
    30
    I also just tested the "Build And Run" method described in the Unity WebGL documentation to get Chrome to run it not as a local file (since Chrome cannot do that), but from a local server and it all came up just fine. It's just the part of being on Facebook where things break down.

    I feel like that is SOME sort of progress...
     
  32. Stormryder

    Stormryder

    Joined:
    May 18, 2013
    Posts:
    9
    I have the same blank page on facebook after following all instructions and settings, yet my game runs on localhost http://localhost:51325/ with the unity build and run command.
     
  33. GarrettCMiller

    GarrettCMiller

    Joined:
    Jan 20, 2013
    Posts:
    30
    Stormryder, what version of Unity are you using? I'm using the latest, which I believe is 2017.2.0f3.
     
  34. Stormryder

    Stormryder

    Joined:
    May 18, 2013
    Posts:
    9
    I'm using the latest as well.
    When I tried the facebook gameroom build, when I launched the compiled exe, the game crushed with the error, failed to load mono.

    I'm sure they are not related. But there's only barebone info out there, it's really hard to troubleshoot.
     
  35. GarrettCMiller

    GarrettCMiller

    Joined:
    Jan 20, 2013
    Posts:
    30
    I haven't tried a Gameroom build yet, but I should probably try. Just to see, if nothing else. But, yeah, at this point it feels nearly impossible to troubleshoot. Very frustrating. I don't even know if it's something wrong with Facebook, Unity, something I'm doing, or even something different! I'm completely at a loss. I don't blame anyone, but damn, I don't think I've ever been this frustrated!
     
  36. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    FYI with Chasmic Rush I tried building on 2017.2.0f1 and it borked - coming up with errors in the console which are impossible to debug really. So I went back to 2017.1 and it built perfectly enabling me to upload the 7z file. Now, apparently it is somewhere on Gameroom and it seems to have acquired a few hundred users playing it :)

    HTH
     
  37. ulebule

    ulebule

    Joined:
    Feb 21, 2016
    Posts:
    2
    Same here. Nothing to see on "Web preview" from FB App Center only white screen. But "Build & Run" from unity opens my Chrome on localhost and runs the game normally. I have Unity 2017.1.1f1 Personal (64 bit).
     
  38. robert878

    robert878

    Joined:
    Feb 23, 2017
    Posts:
    1
  39. dradb

    dradb

    Joined:
    Jan 10, 2015
    Posts:
    86
    Is it likely this will be possible for LinkedIn in the near future?