# Why does my p5js game not work for iPhones?

**URL:** https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891
**Category:** p5.js
**Created:** [June 12, 2018, 7:18am UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891 "2018-06-12T07:18:59Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![helloDolly](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@helloDolly](https://discourse.processing.org/u/helloDolly)
#### Post date: [June 12, 2018, 7:18am UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/1 "2018-06-12T07:18:59Z")

</div>

I made a little game in p5js and can’t figure out why it won’t work for iPhones. For all I know p5js doesn’t work at all with iPhones though so if that’s the case let me know. The game seems to work fine on PC’s and Android phones.

Unfortunately I can’t do much testing for iPhones either as I only have an old iPhone 4 which can’t run much modern stuff or I can call my Mom and have her try to open the page on her phone, but that hasn’t shown to be particularly helpful…

The game can be played at:  
[https://mikenotintheflesh.github.io/SkiGame](https://mikenotintheflesh.github.io/SkiGame)

The code is at:

> **[MikeNotInTheFlesh/SkiGame](https://github.com/MikeNotInTheFlesh/SkiGame)**
>
> Ski through the gates to earn a new high score. Built in JavaScript. - MikeNotInTheFlesh/SkiGame

Thanks for any insight to getting it working for ios (if possible).

edit: eliminated a double negative in first paragraph

---

<div class="post-metadata">

### Author: ![bmoren](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bmoren/32/68_2.png) [@bmoren](https://discourse.processing.org/u/bmoren)
#### Post date: [June 12, 2018, 3:36pm UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/2 "2018-06-12T15:36:51Z")

</div>

can you get a console output while running it on your iphone4?

> **[Remote debugging iOS Safari on OS X, Windows and Linux](https://blog.idrsolutions.com/2015/02/remote-debugging-ios-safari-on-os-x-windows-and-linux/)**
>
> Recently, I have been working on improving mobile support in the content produced by our PDF to HTML5 converter. One problem that I have encountered is how to debug iOS Safari, particularly if you …

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [June 12, 2018, 4:17pm UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/3 "2018-06-12T16:17:41Z")

</div>

Can you get something simpler working? Display a simple hard-coded shape. Then add a small amount of code until you understand what’s causing the problem. Then try to narrow the problem down to a [MCVE](https://stackoverflow.com/help/mcve) so we can help you debug.

---

<div class="post-metadata">

### Author: ![helloDolly](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@helloDolly](https://discourse.processing.org/u/helloDolly)
#### Post date: [June 13, 2018, 11:27am UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/4 "2018-06-13T11:27:40Z")

</div>

So I got everything to display on my iPhone 4 by eliminating two js bugs.

First I had a couple functions which I set a default value for the parameters. Apparently this is a no-no in js but Android and PC let it slide. If you use default params in js they have to be of the ‘null / false’ variety.

Second, I used a few **for loops** of the following variety:

```auto
for (let card of cards) {
    card.x++;
}

```

These didn’t work and I switched them to:

```auto
for (var i = 0; i < cards.length - 1; i++) {
    cards[i].x++
}

```

I figure this is an iPhone4 thing cause it’s old and that is a newish for loop.

This got everything to at least display, but not to start the game. I’m using ‘weinre’ to get a console output from the phone (but it’s not outputting what I’d expect it to, like: console.log(“hello world”);, or error messages ).

My function “function mouseClicked() {do stuff}” doesn’t seem to do anything. It’s supposed to start the “loop()”. However something sends the message “start ios!” to my console whenever the screen is touched.

My googlefu has been unable to decode the meaning of this message (“start ios!”). It’s probably incredibly simple. Does anyone know what it means? Btw: this is the only console msg my phone has sent over ‘weinre’, and I don’t know why ☹

Through the ‘weinre’ console on my PC I can send the “loop()” command to the phone and the game will start up. “mousePressed()” seems to work to move the character around although the iPhone4 runs it very slowly…

Maybe tomorrow I’ll migrate the “mouseClicked()” commands to “mousePressed()”. I tried a quick solution tonight, but it was unfruitful.

Any feedback is appreciated.

Anyone know what this “start ios!” console output is about? Lastly Chrome doesn’t output that message to my console. Only Safari.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [June 13, 2018, 7:21pm UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/5 "2018-06-13T19:21:58Z")

</div>

> [@helloDolly](#):
>
> So I got everything to display on my iPhone 4 by eliminating two js bugs.

This has nothing to do w/ the iPhone version ‘x’ or any other OS at all! 🤨  
We should blame the browser running the app instead! 🤮

Either install an actual modern browser in your own OS or convert your modern JS code to the jurassic ES5 version of it: 👺

> **[Babel · The compiler for next generation JavaScript](https://babeljs.io/repl/)**
>
> The compiler for next generation JavaScript

---

<div class="post-metadata">

### Author: ![dan850](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@dan850](https://discourse.processing.org/u/dan850)
#### Post date: [June 16, 2018, 1:23am UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/6 "2018-06-16T01:23:09Z")

</div>

@GoToLoop To be honest, your comment was a rude way to assist someone. you could have offered this advice in a more respectful tone. Please be more Courteous in the future.

---

<div class="post-metadata">

### Author: ![helloDolly](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@helloDolly](https://discourse.processing.org/u/helloDolly)
#### Post date: [June 16, 2018, 2:44am UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/7 "2018-06-16T02:44:48Z")

</div>

Unable to update the ios beyond version 7, so browser updates aren’t available either.

Good to know the problem is with new js on old software though.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [June 16, 2018, 3:03am UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/8 "2018-06-16T03:03:13Z")

</div>

> **[Looking for a new iOS browser? Here are 7 of the best](https://www.macworld.co.uk/feature/iosapps/best-iphone-browser-2017-3621607/)**
>
> Is Safari really the best iPhone web browser? We put the 6 best iPhone browsers to the test to help you find the best browser for you.

  

> **[Beyond Safari: The Best Web Browsers for iPhone | Digital Trends](https://www.digitaltrends.com/mobile/best-web-browsers-iphone/)**
>
> Browsing the web on a smartphone need not be tough. Check out our picks for the best web browsers for the iPhone.

  

> **[10 smart browser alternatives to Safari for iOS](https://www.computerworld.com/article/3233269/apple-ios/10-alternative-browsers-for-ios.html)**
>
> While all iOS browsers today use the same core rendering engine as Safari, many of them offer additional functions useful in the enterprise. We've rounded up 10 Safari alternatives -- some talkative, some secretive -- for Apple's iOS.

---

<div class="post-metadata">

### Author: ![helloDolly](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@helloDolly](https://discourse.processing.org/u/helloDolly)
#### Post date: [June 16, 2018, 7:42am UTC](https://discourse.processing.org/t/why-does-my-p5js-game-not-work-for-iphones/891/9 "2018-06-16T07:42:27Z")

</div>

All those browsers require iOS 9. My iPhone 4 maxes out at iOS 7. They won’t install…
