gree / gree/unity-webview

Webview low performance on Android devices - HTML5 Games

Open
#711 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Objective-C++
Stars
2.7k
Forks
734
Avg merge
11h 39m
Merged PRs (30d)
1

Description

Hello,

I am having performance issues on some Android devices when playing HTML5 games.

We currently use Phaser for our HTML5 games that are loaded with this webview plugin.

Something quite strange happens to us and that is that when games are run randomly they work with good performance and other times they do not work and they go at 5 or 8 fps.

When they don't work correctly, just restart the unity app and hopefully it will start working, but randomly when you start the app it will run again with low performance.

After digging a bit and seeing what happened, the call to client.GetAsync (Host () + dataPath); makes this happen randomly, that we have a good or bad performance of the webview instance.

More details of the code that causes it to malfunction:

`
public static async Task <byte []> GetRemoteData (string dataPath)
{
byte [] byteArray = null;

    using (HttpClient client = new HttpClient ())
    {
        HttpResponseMessage result = await client.GetAsync (Host () + dataPath);
        result.Content.Dispose ();
        result.Dispose ();
        client.Dispose ();
    }
    return byteArray;
}

`

"I know im returning null is just a testing"

During the awake of the main scene, which is not the scene where the webview is instantiated i call:

manifestRawData = await HttpClientAssets.GetRemoteData ("Android");

This will download a Manifest from a assetsBundle.

Something also that I think is important to comment, is that this happened to me exactly the same but with only creating the UnityWebRequest object.

for example:
UnityWebRequest myWebRequest;

With this, the performance of the webview began to go bad.

I have checked and android:hardwareAccelerated="true"

So what I don't understand is what happens because sometimes it affects the performance of the webview and other times it doesn't?

Maybe a port remain stay open or a process remain open sometimes and sometimes not?

Here is a example of how i see the games:

When it work:
https://user-images.githubusercontent.com/23422849/126300470-410b2372-66ec-46e2-a97e-e85a92c2d84c.mp4

When it dosent work with a good performance:
https://user-images.githubusercontent.com/23422849/126300513-ca31a02d-a1ac-45b6-9092-c0c61e693ad6.mp4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Awake call to HttpClientAssets.GetRemoteData("Android"), including client.GetAsync, and compare it with the reported UnityWebRequest object creation. Reproduce the issue on Android while loading the webview and HTML5 games, using the two linked performance examples as a reference. Done should mean the intermittent low-FPS behavior has a demonstrated cause and is no longer triggered by the reported request path.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp, html, javascript, unity
Domain
mobile, performance, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.