hi everybody
thank you for coming out here this
morning I know this is the first talk of
the game session so I hope you're all
coffee'd up and ready to go we're gonna
talk to you about developing games with
firebase my name's Patrick Martin and I
am a developer advocate with firebase
for games and I'm Justin Broughton I'm
the engineering lead for firebase test
lab and I'm John scrip I am a software
engineer with Google specifically
working on the firebase growth team
sorry with with that we'll we'll let
Patrick take it away well we have a
brief map of where we're gonna go today
on a kind of a fun adventure I will talk
about building games of firebase and
I'll talk about the exciting adventure
of testing games with firebase and then
I will talk about growing your your game
with firebase and now we will let pass
now you're free to go let him go just
one more brief piece of bookkeeping
we're only going to scan skim the
surface of firebase today if what we
talk about sounds interesting to you
we'll be right back there with MECA
hamster so you can ask questions as well
as there's a firebase tent over there so
with that let's get to building games
with firebase so I want to give you all
a little bit of my background I started
about a decade ago making mobile social
games and then I eventually got into
prototyping with actually robot toys and
typically I find that the tool set for
each of these is normally astoundingly
different right with a prototype you're
just you just care about getting to the
next checkpoint getting like approval to
work on it more whereas long-standing
like ship titles need to be accessible
from all over the world at all times of
day and you know there are just
different considerations but I think of
firebase is really good at bridging the
gap so as game developers as I assume
many of you are here today as game
developers we do not have the luxury
right of just
just looking at a game design document
implementing everything by the letter
and hoping we get a good game out at the
end we're always questioning what we do
and always trying to make sure that what
we built is fun and interesting and I
think firebase helps because it shortens
the distance from that idea you have the
wanted test to the implementation and
experimentation they'll tell you whether
or not it's something you want to run
with and even though in it gets a lot of
the backend architecture stuff out of
the way but if for whatever reason you
find that we've made the wrong
abstractions for your particular
situation firebase is a Google cloud
product and at any point you can switch
over to the Google cloud dashboard and
just pick up right from where you left
off and build out whatever you need but
I'm gonna focus today actually on using
firebase and trying to show how easy it
is to work with by augmenting the single
player game called Mecca hampster this
is a open source project again we have
it back there in the garage that we use
as our testing ground for every new
feature we add to firebase for unity
it's a very simple game you tilt your
phone to get hammer the hamster over
here to the end of this maze a lot like
those wooden marble mazes you probably
played with as a kid
let's see so what we're going to do is
add a level editor to this game there
are a lot of reasons to do it one of
them is so I can talk to you guys up
here about real-time database but also
you know it will help improve the
developer experience let designers to
build a level then test it immediately
just by clicking this play button also
I'm based out of Colorado a lot of my
co-workers are out in California or out
here so it'd be really awesome to have
this share button so they can send a
level to me immediately and get my
feedback without having to wait for like
the build server to kick something out
so of course we used real time database
this is really neat to me at least
because it represents all of your data
is a large JSON document which unity has
built-in serializers to and from so
there's not much custom code to write to
support this
it's synchronized in real time as its
name probably implies as game developers
I should warn you that this isn't this
is not real time like quake three
dedicated server I'd recommend checking
out agonies for something like that but
if your experience can be like Google
Docs multiple people working on one
document this is a perfect tool or it'd
be awesome for asynchronous multiplayer
games it's also cached if you've worked
on these kind of mobile social whatever
sort of game you probably have
experienced the all the annoying corner
cases around the user went into a tunnel
and did something right so everything
you do is cached offline is transactions
you can query the database immediately
to see what your current state is and
when you reconnect to the Internet
rather than just replacing this data on
the server with your local copy you
replay the transactions they got you
there that way if you're scoring if
you're storing score for instance you
don't just replace a potentially higher
score with a lower one you have on
device you just add ten points or
whatever the alarm des function is you
provide to the transaction and there is
something else I am a front-end dev and
I get super nervous when it comes to
exposing back-end stuff like this to my
users so it would be really awesome if
firebase had some way to let me securely
share this information without you know
without eleven nervousness that comes
with writing custom server code for that
we actually have a verbose rules that
JSON file that you can store next to
your database this is a JSON document
and right here this is a small snippet
I'm saying the DES mapless so all the
maps in the game are readable by anyone
with this database URL but with a small
change I can restrict it to only
authenticated users now you may realize
at this point it's still not secure but
since this takes a JavaScript like
syntax you can do something like store
the UID of the creator of a map in that
map node and verify it here and you know
it's running on a secure
server in a way that an attacker would
have a really difficult time spoofing
credentials and this comes from
something called firebase authentication
and Mecca hamster we opted to use email
address and password as our
authentication mechanism as well as
something called anonymous off which I
know sounds a little weird but all
anonymous authors is a unique identifier
associated with a combination of game
and device so the same game across
multiple devices has different
identifiers as does different games on
the same device but it's a really nice
way to just give your users an easy
single click button to access your
online components knowing later that
they want to migrate up to a better a
different off method so I mentioned that
we use email address and password this
is not me rolling my own off system this
is a product from firebase it just has
credentials unique to your game but we
also support all of these other identity
providers and as I mentioned they
support merging and migrating accounts
so a gain center for instance is a new
integration if you have an existing
firebase game on the market using
authentication you can just integrate
the game center Client SDK turn it on in
the firebase cloud console and then
prompt your users to merge their account
with the game center one and now they
have that one-click experience that you
know your iOS game players probably
expect from other games just seamlessly
integrated to your own now I would love
it if all of you got really wild up and
ran home and use like firebase right now
right but I know that that's
unreasonable and it's even hard for me
do I hand you this open source game and
say look at it and decide if this is
right for you
so we created this project called Unity
solutions on github and in particular we
have this firebase leaderboard solution
this implements a leaderboard which many
games require one of those directly on
top of real time database so you can try
firebase in your
project in your codebase and see if it's
right for you and if it's not it's
really easy to take out a leaderboard
but at least I think it's really fun and
you'll get a kick out of using this and
as I mentioned we test everything in
mecha hamster including the code path
that all of you would use if you
integrated this firebase leaderboards
and in particular since it's open-source
we want you to expand upon it so we and
mecha hamster decided to try adding a
replay system so you see how someone got
that really awesome two millisecond
score and easy breezy right obviously
like the naive approach what I might do
when I first approached this problem is
just hit the data I have the memory with
for the replay with Unity JSON
serializer and try to drop that into the
real-time database but at some time at
some point this database isn't real-time
just because there's so much data you're
trying to send over the wire in this
case in a proto buff which is the format
we're using this is 30 to 60 kilobytes
you can probably easily double that for
a JSON file so we decided to use cloud
storage for firebase this is a key value
storage solution it's another kind of
database that lets you store a key which
is just a string path as well as any
arbitrary binary blob so in our case
replays but could be player avatars
videos if you wanted you could probably
even put like apks and binaries up there
and our flow becomes when you get a high
score log in the leaderboard but at the
same time start uploading the replay
data to cloud storage you get a call
back when that completes it
synchronously and at that point we can
store a reference to the file we just
uploaded in a new node we added to the
RT DB there is still one other problem
now we have high scores in two locations
if you're like me most games I've
shipped with a leaderboard I've been
I've been on it on like at the point I
click the publish button
I might even had the high score on a
particularly small game but within the
I'm just gone by like an
order-of-magnitude right
it would really stink if I was always
paying for that cloud storage space for
this replay effectively from day zero
for the rest of the game's lifetime and
you can't really rely on user clients to
behave well and clean up all this data
as a new score goes off even in the best
case scenario someone's like phone might
just stop working like they drop it in
the ocean or something in the process of
uploading a score so we use cloud
functions to listen for when a node is
added to some path in the high score
board and then perform our clean up in
this case check to see if there are more
than five high scores and get rid of the
associated replay data now cloud
functions there are brand new outta beta
they let you run mobile backend code
without managing servers they're written
in JavaScript or typescript and they're
also secure just like real time database
if you create something called a
callable function you get a end-user SDK
to integrate it with your client app
you'll automatically get the users login
credentials and their pre verified by
the time your code executes and not only
can you communicate between different
firebase products but you can also
communicate between firebase and the
rest of the Internet so if I were to try
to call out some use cases that you
might want to use in a video game could
be if you're making board games let's
say you're making a Monopoly battle
royale right someone's gonna figure out
how to always roll doubles in jail so
roll your die in a cloud function very
easily store the result in a real-time
database you've mostly eliminated the
potential of cheating if you have gotcha
mechanics a lot of games now have loot
boxes for monetization some user is
going to figure out how to make every
loot box a Gjallarhorn if you let them
claim with their prizes so again rolling
the server distributed it distribute it
through a real-time database or some
other mechanism and you have control
later on John's actually going to talk
about another product called crashlytics
you can listen for when a new crash
happens you know automatically log a bug
in JIRA for your team
you can even get a call back when a bug
sprites and prevalence and send an SOS
to your team slack to be like hey guys
drop everything and take a look at
what's happening all of a sudden so
patrick we were talking off stage about
some of the horror stories that you
experienced while developing games what
are some of the most horrible things
that you ran into I mean there was a
time when I dropped a game from five
stars to one overnight which I'm sure
you were popular when you did that that
was that was a hard week there was also
a time when a producer on a contract
product I was working on actually
managed to get my phone number at
midnight and called me with an issue
where I was getting a blank screen on
only a device his like friend had but of
course it was a contract or contract II
so he had the final say and whether or
not our game was approval ready so you
know I ran through tour through our
entire device inventory could not
represent ill people started showing up
the next morning so if only you'd had
access to firebase test lab which is
perhaps the most contrived segue ever
you still earn this thank you so much
all right so we're gonna turn our
attention to testing games with firebase
and so for all you games testers out
there when we test games what are we
looking for well in some respects games
are just like applications so we we're
looking for signals which might indicate
a problem or a bad experience such as
slow startup time we're looking for
crashes which give a particularly bad
experience to the user we're also
looking for incorrect behavior when the
app or game does not behave as we intend
or as the user expects but games are
different in the sense that we care
about the rendering performance that is
because games provide an immersive
experience that is seriously damaged if
the rendering is janky or slow so what a
what when devs what a test dead devs
doing today around testing well from
talking to
any of you there's a whole hell of a lot
of manual testing going on there is some
automated testing but it's generally
homegrown so it doesn't work outside of
the game engine that you're using or
indeed out of the company which you work
so the question is why do we care well
obviously we care mostly because of the
expense training all of those testers to
get to some of the late levels in your
game and then manually testing across a
variety of different devices and
verifying the results it's pretty
expensive and then the testing needs to
be repeated on every single release of
your game the testings also done late
which means you don't find the problems
early when they're cheaper to fix and
lastly there's no safety net for your
developers which means that they've no
idea of any change they're about to make
it's gonna break the game in some
fundamental way so why a game stairs not
flocking to automated testing well as it
turns out testing games is pretty hard
firstly games are rendered with OpenGL
or Vulcan or some other opaque
frameworks so the testing tools that you
can use for apps like UI Automator XC UI
tests espresso don't work for games
games also offer a wider array of inputs
you can imagine games like World War
Craft or clash of clans where you're
basically placing your characters or
building your towers anywhere you like
on the screen so the number of inputs is
virtually infinite games are often
deliberately unpredictable this is
because we want to give a different
experience to the user every time they
play the game and often the issues
within games are really hard to reach
you can imagine that your favorite ogre
on level 10 is dying and you've no idea
why so I've been still quite recently
the only generally available option for
testing games was monkey testing which
was not particularly healthful but
it rarely gets very far into the game to
be useful
it also doesn't exercise the game as a
human would be sure you may not even
care about the problems it finds it's
good for finding crashes on startup but
very little else so before we get into
some of the testing solutions that I'm
going to present I want to first
introduce you to firebase test lab this
is something I've been working on for
about the last five years or so firebase
s lab is part of the suite of
application policy products in firebase
it allows you to test your app or game
in the cloud across lots of different
devices including some high end gaming
devices and as of today Android Q and
even we're devices so if you're building
a game for wear then you can now test it
on test lab you can also test on iOS and
Android on physical devices on virtual
devices in different languages and
locales and of course with different
screen orientations and you get
comprehensive test results including
video and screenshots and performance
metrics so startup time most importantly
for games frames per second and network
and CPU and memory all synchronized with
the video so you can see what's
happening in your game at the time that
you see some spike in some or some
problem in your metrics you also get
crashes and logs and much more now
firebase test lab is also the engine
behind the play pre-launch report so how
many of you here have you've heard of or
use the pre-launch report hands up not
as many as I hoped all right play
pre-launch report is a free report
that's a free report where you get
testing for free by simply uploading
your game into the testing track within
the Play Store so take advantage of that
so we've heard from many of you that the
security of your game is incredibly
important much more so than even for
application developers this is is
because the leak of a pre-production
game would be absolutely disastrous
that is why we completely clean up the
device between test runs so that in most
cases where simply flashing the device
we also do a security check on the
submitter of the game as well as the
game itself so how much is this gonna
cost me I hear you ask well I don't hear
anybody asking because a bit early in
the morning for heckling but it's gonna
cost you about $1.00 per hour for a
virtual device and five dollars an hour
for a physical device but the trick here
is we only charge you for how long the
test runs we don't charge you for how
long it takes to install it to pull the
results off the device to ship them off
to device storage to post-process them
whatever if we only charge you so if you
send a test and you ask to test for five
minutes on a pixel to say running
Android Q it'll cost you about 40 cents
which is pretty cheap so really there's
no excuse not to implement some
automated regimen of tests for your game
which brings us to how you might go
about doing that so firstly it's
important to prepare your game for
testing so you can upload a special
build to test lab or you can build
testability into your game there's a
special property you can check for that
tells you whether you're running in test
lab now there are many things that you
can do to make your game more testable
I'll talk about a few of them you could
for instance remove part or all of the
game preamble from login registration so
you can get to level one pretty quickly
allow your tests to focus on that you
could also remove randomness from the
game so that your tests see the same
game each time and they know they're not
flaky you could also start the game at a
specific level maybe increasing the
experience of your characters or giving
them artifacts so that you can test some
of those later levels so you can run
lots of different kinds of tests on test
labs
some of them are targets specifically at
games one test which requires little
really no effort on your
is robo robo is a framework of different
application crawlers that are used under
different conditions
so when robo sees and of Paik screen
such as that rendered by opengl it will
switch to the enhanced monkey action
scroller
this is a crawler that uses machine
learning to interpret what's on the
screen and interact with those screen
elements now robo shows a yellow circle
which you can see on the bottom right
there within the video whenever it
interacts with the screen so you can
tell that it's about to click on the
let's roll button which is exactly what
it needs to do to actually get to level
1 and as of IO and that's not going to
be very readable to half of you in the
back but that you can now run Robo
locally which means with this link you
can download a version of Robo and run
it against your own games and that's
available to you as of either with a
little more effort you can actually
record test scripts and execute them
locally or run them in test lab last
year at the games development conference
in San Francisco we announced a
partnership with Nettie's now these is
one of the largest game companies in
China they developed an integrated
testing environment they use for testing
their own games and they made it freely
available to anybody they also open
sourced a couple of testing frameworks
including air test which uses image
recognition to interact with the games
they also open source poco which uses
instrumentation in the game engine to
allow it to Ted the test to interact
directly with the games their support
for unity and Co costs and even the
android framework you can record scripts
with the game running locally and then
you can package them into
instrumentation tests and upload them to
test lab where you can run them across a
variety of different devices and when
the UI changes as it always does you
simply rerecord the tests it's that easy
and thirdly we have game loops game
loops allow you to define critical user
journeys through your game you can do
say one critical user journey one game
per level or maybe one per character and
mecha hamster which Patrick talked about
earlier and you can see behind me has a
built-in game loop so check it out
and also the pre-launch report that I
mentioned earlier will preferentially
run a game loop if it finds one in your
game so if you upload a game with a game
loop in it to the pro to the Play Store
you get free testing of your game loop
so when should use each of these
different kinds of tear testing so robos
really good for testing the game
preamble it's also great if you don't
have any tests yet it's also used as it
is by some application developers as a
last-ditch attempt to make sure you're
not doing something stupid as you push
to production so maybe a smoke test err
test is good for navigating the UI and
basic gameplay and game loops which test
the same critical user journey each time
a really good for catching performance
regressions so now all you have to do is
add those tests that you built your CI
system and I assume you all have a CI
system right so that every time you make
a change it can be much more confident
you do not break the game in some way
which makes your developers happy it
makes your users happy which is
ultimately what we want so now I've
completely put you to sleep talking
about testing we're gonna wake John up
hey John thank you so much bass help
once you push your game out into the
wild great question so basically at this
point you have your game built you have
your game tested and things are fairly
stable let's say where do you do what do
you do there's a lot of options and I'm
gonna start with predictions the reason
I'm going to start with predictions is
because it's so simple to enable all you
need to do is literally go to the
console and click the button to enable
it from this point on predictions will
use machine learning to start
pacifying your user base into predictive
groups by default it will start
predicting who will spend or not spend
and who may turn or may not turn but
this is fully extendable with any sort
of custom events that you would like to
add into your game so what do we do once
we have some groups that we want to
target a be testing is a great place to
start setting them up is super easy all
we need to do is first we need to select
our target users so let's say we use our
predictions from the prediction service
and let's target our spenders our
potential spenders because money is good
we like that we next need to create
variants which are the things that you
want to test the changes that you want
to test will say that you have some
remote configuration parameters that you
would like to work with maybe you have
some seasonal aspects within your game
you want to run a winter event because
it's winter and for our goal we can say
our potential spenders let's see let's
see who's gonna get excited about this
with this winter event and let's see
who's gonna spend with remote config we
can then deploy these changes if we find
that they are successful and we have our
hammy snow day event but this is also
you don't have to go through an a/b test
so say we did this test and you find out
that seasonal events are great spring
rolls around and you know that these
seasonal events are working you don't
have to go through an a/b test you can
go directly through remote config you
just change your parameters that you
have programmed into your game and you
can launch a spring event or summer or
whatever remote config is super useful
and this is this is barely even
scratching the surface of the things you
can do with it
so things are going great you're making
changes you are gaining users stuffs
happening maybe you're moving too fast
maybe you didn't test as well as you
probably should have or maybe just some
edge case was discovered this is about
the last thing that you want your users
to see within crashlytics console you
get information such as the frequency
the device type C OS version really the
who what where when why and how many
times your game has crashed what's
really useful as it gives you the sack
traces the likely stack traces back to
your code so you can easily diagnose
issues within your game and as Patrick
mentioned you can also rig this up to
alert you or your team which is super
useful I would recommend integrating
with crashlytics if you even if you
don't integrate with any other part of
firebase it's super useful and one
notable point is that crashlytics is now
integrated with unity this means you can
take your unity at your Unity game and
you can integrate directly with
crashlytics get the same insights into
your game as you would with a native
application or really anything else that
is outside of unity so this is super
exciting for game developers
so maybe you've had some crashes or
maybe not maybe you just want to alert
your users to some exciting news cloud
measures messaging allows you to target
your users in the same way that you
would target them elsewhere you could
use your predictive groups if you want
you could send it to everybody you could
really really target any other any other
use achmet user metric that you have
available and I want to mention cloud
messaging because it's it's just so
straightforward you you target and you
create your message that's it you send
it I should also note that these are a
be testable as well so if you want to
target a subsection of your user base
you can test out different variants of
your notifications and see which ones
are most effective whose clicking on
them the most so with all of this how do
you know that things are actually going
well or maybe things are not going well
within your game firebase analytics
gives you a bunch of insights really all
the insights that you would want into
your game performance here we can see
some mock data for mecha hamster the
things things you can see in the
analytics console include revenues where
you're like what countries your game is
the most popular in where where your
usage is coming from and you can rig up
really any other type of custom events
that you have trigger within your game
as well so it's super useful for
tracking funnels and and things like
that so I'd like to invite my friends
back up here as we have gone over a
plethora a smorgasbord of features
within firebase just to kind of wrap
things up and and go over what we hope
you have learned today so we'll start
with Patrick yeah as I mentioned I
really think the firebase will help you
shorten the distance from any idea you
have
to its implementation and would
encourage you to give it a chance even
in a game jam situation and of course I
talked about a number of different ways
that you can test automatically your
games so I really encourage you to take
advantage of those and I have gone over
just really a quick-fire of available
features within firebase that I urge you
to leverage and experiment with there's
so much provided out of the box that
it's it's really worth your time to
discover what firebase cannot be less or
all of it
a plethora and with that that will
conclude our talk thank you so much for
attending thank you everyone for
watching online and come see us in the
firebase in Beckenham sandbox
[Music]