Performance penalty when running game in a game using iFrame

Discussion and feedback on Construct 2

Post » Sat Mar 29, 2014 7:47 pm

Hi @Ashley, all,

If i were to run one or many C2 games within a Game using the iFrame plugin, would this cause significant performance degradation?

Why yes: because C2 runtime, runs two or many times in parallel, creating both memory usage and processing overhead

Why no: because in the end all C2 game instances run on the same processor, and hence processing is time shared overhead is similar to running all games within one C2 game.

Which argument is correct?

If there is significant overhead could in principle the code be optimized to recognize multiple instances of C2 being loaded in a browser?

thank you,

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Mar 30, 2014 5:22 am

C2 doesn't load in the browser, it is a desktop app... Your games(canvases) load in the browser. if you run multiple games via iFrame you are getting the overhead from all of them (unless they unfocused iframes pause themselves).

I have found very few cases where it is the CPU that is the bottleneck so the timesharing is less important than video memory unless all your games are physics games.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Sun Mar 30, 2014 5:36 am

Hi @BluePhaze,

(I just posted a reply but it seems to have gotten lost), so here again:

Indeed, my question was about performance of exported games. I am wondering if there is a difference in performance if "games inside games" are run within one exported C2 game or whether each run in an iFrame.

Daniel

p.s. I would need to check the non-focus item you mentioned. I would want the game inside the iFrame be responsive at all time, not only when it has focus.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Mar 30, 2014 12:52 pm

It would probably be very slow, not because there's anything particularly inefficient about iframes, but just from the fact a typical game will use up a fair bit of CPU/GPU/memory, and running several at once will use a multiple of the system resources. Desktops might get by but I'd imagine it'd choke mobile devices.

What are you trying to do? Why are you asking the question? If you want to make a menu in an iframe, it's a very inefficient way to go about it since you get the overhead of an entire game engine just for the menu by itself. It'd be better just to design it in-game itself. However if you're making some kind of arcade, it would of course be better just to run one game at a time!
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Sun Mar 30, 2014 12:58 pm

Thank you @Ashley,

What i am trying to do is to break down my quiz game into game "components" with which to construct quiz screens. A component would be in part layout elements and in part associated events.

For example, I designed a visual keyboard (going from "A" to "Z", working in English and Hebrew), and want to include the keyboard in various quiz screens -- those for which an entry is required.

So, instead of replicating the keyboard layout elements and event sheet across all screens, I want to include a keyboard component only, as a whole, in a new quiz screen.

Using iFrame and HTML5 Messaging as implemented by the postMessage plugin seems to enable doing that. But, the overhead this would create may in the end be a bottleneck.

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Mar 30, 2014 1:04 pm

Btw, I understand that I can include events, and I am indeed making extensive use of "includes", for example, to "automatically" internationalize all Quiz screens. But, sometimes I need to include both layout elements and associated events, and C2 currently does not support such kind of combined reusable "components" "out of the box".
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Mar 30, 2014 1:15 pm

Do not use an iframe for that. What's stopping you designing it in one project only?
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Sun Mar 30, 2014 1:23 pm

HI Ashley,

Thank you for your prompt response.

I can of course replicate the keyboard and other design elements across quiz layouts.

But, I am going to include the keyboard in, say, 15-20 screens, and duplicate other kinds of design elements across various screens, and as requirements change, and they will change, since we are doing participatory design -- I have to redo all screens, one at a time -- all layout elements that can not be reused. Its tedious and error prone.

It would have been nice if there is one location where I make the change and the change propagates across all layouts. Perhaps such modularity is not a strong requirements in game design, and my quiz game is unusual that it reuses design components across screens.

Dan

p.s. Also, i want to avoid parameterizing screens, and events, to facilitate reuse, since it reduces the readability of the event code, and there are always exceptions you need to deal with, which make things even more complex.

EDIT: Also, i think the simplicity of C2 event coding, which I appreicate a lot, is lost to a greater extend when I parameterize for reuse. I've tried it, and then i found myself spending time debugging reuse code rather than improve the games themselves.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Mar 30, 2014 1:32 pm

Hi,

would it not be better to spawn the UI elements at the start of each layout. This way you just have one set of elements to change.
B
49
S
16
G
9
Posts: 1,098
Reputation: 11,222

Post » Sun Mar 30, 2014 1:41 pm

Thank you spongehammer.

The problem with Spawning is that they obscure the actual visual layout by pushing the layout elements into code. A key strength of C2 in my mind is that its visual programming which makes it easier to understand, program, maintain and change. This means that if you want to do reuse you have to move away from this paradigm.

BTW, the keyboard is mostly spawned from one letter, but there are still layout specific design elements included.

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 3 guests