Using the webbrowser with Android and WebRTC - 4.20

Hi!
I’m creating a small VR app that requires two web browsers playing at the same time. It works flawlessly on PC, but the resolution and framerate go super wonky on an android phone.
Also, the only seems to be working just a properly resolution (without any kind of stretching) which is 500x500. I’ve found that value hardcoded in two android web browser constructors, both C++ and Java, but when trying to change that value to any other number, I meet the following error:


Error        'USE_ANDROID_JNI' is not defined, evaluates to 0 -Werror,-Wundef]    VNT_Android_Opt C:\...\UnrealEngine\Engine\Source\Runtime\WebBrowser\Private\Android\AndroidWebBrowserWindow.h    5  

The code I’m changing is:

Inside AndroidWebBrowserWindow.cpp


 FAndroidWebBrowserWindow::FAndroidWebBrowserWindow(FString InUrl, TOptional<FString> InContentsToLoad, bool InShowErrorMessage, bool InThumbMouseButtonNavigation, bool InUseTransparency, bool bInJSBindingToLoweringEnabled)
    : CurrentUrl(MoveTemp(InUrl))
    , ContentsToLoad(MoveTemp(InContentsToLoad))
    , bUseTransparency(InUseTransparency)
    , DocumentState(EWebBrowserDocumentState::NoDocument)
    , ErrorCode(0)
    , Scripting(new FAndroidJSScripting(bInJSBindingToLoweringEnabled))
    , AndroidWindowSize(FIntPoint(500, 500))
{
}

To:


FAndroidWebBrowserWindow::FAndroidWebBrowserWindow(FString InUrl, TOptional<FString> InContentsToLoad, bool InShowErrorMessage, bool InThumbMouseButtonNavigation, bool InUseTransparency, bool bInJSBindingToLoweringEnabled)
    : CurrentUrl(MoveTemp(InUrl))
    , ContentsToLoad(MoveTemp(InContentsToLoad))
    , bUseTransparency(InUseTransparency)
    , DocumentState(EWebBrowserDocumentState::NoDocument)
    , ErrorCode(0)
    , Scripting(new FAndroidJSScripting(bInJSBindingToLoweringEnabled))
    , AndroidWindowSize(FIntPoint(1280, 720))
{
}

Just the last line. It makes the project uncompilable.

So I thought it might be hardcoded somewhere else, and I found it on WebViewControl.java (Build/Android/Java/src/com/epicgames/ue4):


private static int initialWidth = 500;
private static int initialHeight = 500;

Is there any need to regenerate something before changing the android’s related code?

The whole combination of problems I’m experiencing with Android web browser inside VR is:

  1. Slowness: Framerate of the video on PC is around 20fps (that’s what we are sending from the server, so it is ok), android 1 - 2 fps when its best.
  2. Resolution madness: It will ignore any changes on the widget and just stretch the image somehow. Is there any kind of documentation around this? Standard UI documentation on Android does not work properly with the integrated Web browser.

Thank you for reading me!
I would appreciate any kind of light shed on this issue.

Cheers,

To anyone wondering, it was an issue with the UnityBuild system for building the project. In the very beginning of the build, a message saying that the class AndroidWebBrowserWindow was excluded from the unity build, causing it to lose all the references to anything previously define, just like the USE_ANDROID_JNI or any other definition.
After some obscure digging in the forums, I found this:
Link to the post
In which they explain a bit about the UnityBuild system.
So, in the end, having this file as BuildConfiguration.xml



<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
    <BuildConfiguration>
        <bUseUnityBuild>false</bUseUnityBuild>
    </BuildConfiguration>
</Configuration>


Under Engine\Saved\UnrealBuildTool.…
Seems to have fixed the build issue. Furthermore, the problem with the resolution was not on the .java file, it seems the android desired size of the browser is hardcoded to 640x480… So… yeah, changing it to our expected resolution fixed the first issue also.

Cheers,

1 Like

I have the same problem on the Oculus Quest, the web browser can’t render at more than 500x500, whatever I do. I tried changing the build config xml, but with no luck.

Using 4.23

I’m also having trouble playing on the Oculus Quest. The web browser won’t let me play in anything higher than 500x500, no matter what I do. I tried modifying the build configuration XML, but without success.

in my android web browser nothing works. can you explain how to work 500x500 to ue4 android game?