Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRITICAL] core script makes lots of cache textures #208

Open
Creta5164 opened this issue Sep 22, 2019 · 5 comments
Open

[CRITICAL] core script makes lots of cache textures #208

Creta5164 opened this issue Sep 22, 2019 · 5 comments

Comments

@Creta5164
Copy link

Creta5164 commented Sep 22, 2019

image
image
iOS application debug log

2019-09-21 19:22:39.039393+0900 StarryNight_swift[12541:3674519] [ProcessSuspension]  0x2834ca780 - ProcessAssertion() Unable to acquire assertion for process with PID 0
2019-09-21 19:23:09.041738+0900 StarryNight_swift[12541:3674258] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

JS console debug log

[Error] Failed to load resource: The requested URL was not found on this server. (pixi.js.map, line 0)
[Error] Failed to load resource: The requested URL was not found on this server. (pixi-tilemap.js.map, line 0)
[Error] Failed to load resource: The requested URL was not found on this server. (pixi-picture.js.map, line 0)
[Warning] Total canvas memory use exceeds the maximum limit (288 MB). (rpg_core.js, line 1481, x2)
[Warning] Total canvas memory use exceeds the maximum limit (288 MB). (rpg_core.js, line 754)
[Warning] Total canvas memory use exceeds the maximum limit (288 MB). (rpg_core.js, line 754)

We are porting MV games to iOS and found the following flaws in the core script.

This problem is quite serious and is not very well suited to RAM optimization and modern GPU rendering methods.
Our game dev team have confirmed while porting to iOS, core script makes cache texture just one time uses for making every windows. (even when moving window cursor too...)
This approach is extremely inefficient.
Because of this problem, the web view we used to port to iOS, WkWebView, opens and closes the menu dozens of times, causing the web view will refresh page by cannot handle the huge memory heaps. It's very serious.

Here is reason:

  1. Making cache texture (using canvas) are makes huge memory heaps, so it'll needs more huge memory space and garbage collector(GC) will takes cleaning for long time. The real problem is that only GC knows when to clean. (GC will clean even playing game, that makes freezing the game)
  2. Make every window using instant texture, then GPU will wait for next uploaded texture from CPU for drawing, every each frame! this is must be avoided with optimization.

There are two alternatives:

image

  1. Create a blank canvas of 2048x2048 size, and draw in here and display it every time create a window. This is called dynamic texture. (only use one texture for displaying everything.)
  2. Representing every window elements as Pixi's default objects. Because Pixi's assets are all managed objects.

Dev team should know why need to be more concerned about VRAM and RAM optimization issues, please check the link below.

What is a sprite sheet?
What is a sprite sheet? - Performance

@krmbn0576
Copy link
Collaborator

Thank you for your report!
I don't know much about rendering, so it's better to let Pixi manage it.

@Creta5164
Copy link
Author

I think it's going to require quite a lot of changes to core scripts in second option.
If need optimizing in a short time, I would recommend a dynamic texture solution.
I think this method can be expressed in the same way as it is now without creating many additional canvases.

If the situation is not good and there is no other way, I recommend the second option.

@krmbn0576
Copy link
Collaborator

@Creta5164

Sorry for the late reply, but I'm still interested in your agenda.
Certainly the first method seems to be better. But since it is very technical, it may be wrong if I implement it.

Could you write a pull request?
I don't know if the publisher will officially release it, but we can publish your proposal as a new open source version on Github.

@Creta5164
Copy link
Author

Creta5164 commented Oct 2, 2019

Sorry, but I'd not currently have enough margin of time to contribute significantly to this project.
So I created a demo to actually demonstrate the concept of dynamic textures.

demo
jsfiddle demo

Pixi has a RenderTexture, that makes it possible to draw Pixi's DisplayObject.
This demo shows a demonstration of creating elements of a window into a Pixi Sprite, drawing a window on a RenderTexture, then tearing it off and recreating it into a Sprite.

This is a simple demo, and in order to actually use it, this will need function about lot of drawing and erasing textures to use dynamically in the RenderTexture. (Dynamic texture)

Check this post for how sprite packing algorithm works.

@krmbn0576
Copy link
Collaborator

Thanks!
I will study more about rendering ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants