bEnableDomStorage

bEnableDomStorage

#Overview

name: bEnableDomStorage

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bEnableDomStorage is to enable or disable DOM storage API for WebViews in Unreal Engine projects targeting Android platforms. DOM storage allows web applications to store data locally within the user’s browser, providing a way to retain state and improve performance.

This setting variable is primarily used in the Android-specific WebBrowser module of Unreal Engine. It’s referenced in the AndroidRuntimeSettings and utilized in the implementation of the Android WebBrowser widget.

The value of this variable is set in the Android Runtime Settings, which can be configured through the project settings in the Unreal Engine editor. It’s defined as a UPROPERTY with the GlobalConfig flag, meaning it’s stored in the engine’s configuration files.

The bEnableDomStorage variable interacts with other WebBrowser-related settings, such as bEnableRemoteDebugging and bUseTransparency, when initializing the JavaAndroidWebBrowser object.

Developers must be aware that enabling DOM storage can have implications for data persistence and privacy. It’s important to consider the security implications of storing potentially sensitive data on the user’s device.

Best practices when using this variable include:

  1. Only enable it if your web content specifically requires DOM storage functionality.
  2. Be mindful of the data being stored and ensure it doesn’t contain sensitive information.
  3. Consider the impact on performance and storage usage, especially for memory-constrained devices.
  4. Test your application thoroughly with DOM storage both enabled and disabled to ensure proper functionality in all scenarios.
  5. Document the use of DOM storage in your project’s privacy policy if applicable.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:3093, section: [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:697

Scope (from outer to inner):

file
class        class UAndroidRuntimeSettings : public UObject

Source code excerpt:

	// Enables WebViews to use DOM storage API
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Misc", Meta = (DisplayName = "Enable DOM storage for WebViews"))
	bool bEnableDomStorage;

	virtual void PostReloadConfig(class FProperty* PropertyThatWasLoaded) override;


#if WITH_EDITOR
	/** Called whenever a registered Android property changes. */

#Loc: <Workspace>/Engine/Source/Runtime/WebBrowser/Private/Android/AndroidJavaWebBrowser.cpp:33

Scope (from outer to inner):

file
function     FJavaAndroidWebBrowser::FJavaAndroidWebBrowser

Source code excerpt:


FJavaAndroidWebBrowser::FJavaAndroidWebBrowser(bool swizzlePixels, bool vulkanRenderer, int32 width, int32 height,
	jlong widgetPtr, bool bEnableRemoteDebugging, bool bUseTransparency, bool bEnableDomStorage, bool bShouldUseBitmapRender)
	: FJavaClassObject(GetClassName(), "(JIIZZZZZZ)V", widgetPtr, width, height,  swizzlePixels, vulkanRenderer, bEnableRemoteDebugging, bUseTransparency, bEnableDomStorage, bShouldUseBitmapRender)
	, ReleaseMethod(GetClassMethod("release", "()V"))
	, GetVideoLastFrameBitmapMethod(GetClassMethod("getVideoLastFrameBitmap", "()Lcom/epicgames/unreal/WebViewControl$FrameUpdateInfo;"))
	, GetVideoLastFrameDataMethod(GetClassMethod("getVideoLastFrameData", "()Lcom/epicgames/unreal/WebViewControl$FrameUpdateInfo;"))
	, GetVideoLastFrameMethod(GetClassMethod("getVideoLastFrame", "(I)Lcom/epicgames/unreal/WebViewControl$FrameUpdateInfo;"))
	, DidResolutionChangeMethod(GetClassMethod("didResolutionChange", "()Z"))
	, UpdateVideoFrameMethod(GetClassMethod("updateVideoFrame", "(I)Lcom/epicgames/unreal/WebViewControl$FrameUpdateInfo;"))

#Loc: <Workspace>/Engine/Source/Runtime/WebBrowser/Private/Android/AndroidJavaWebBrowser.h:15

Scope (from outer to inner):

file
class        class FJavaAndroidWebBrowser : public FJavaClassObject

Source code excerpt:

{
public:
	FJavaAndroidWebBrowser(bool swizzlePixels, bool vulkanRenderer, int32 width, int32 height, jlong widgetPtr, bool bEnableRemoteDebugging, bool bUseTransparency, bool bEnableDomStorage, bool bShouldUseBitmapRender);
	virtual ~FJavaAndroidWebBrowser();
	void Release();
	bool GetVideoLastFrameBitmap(void* outPixels, int64 outCount);
	bool GetVideoLastFrameData(void* & outPixels, int64 & outCount, bool *bRegionChanged);
	bool GetVideoLastFrame(int32 destTexture);
	bool DidResolutionChange();

#Loc: <Workspace>/Engine/Source/Runtime/WebBrowser/Private/Android/AndroidWebBrowserWidget.cpp:121

Scope (from outer to inner):

file
function     void SAndroidWebBrowserWidget::Construct

Source code excerpt:


	// Check if DOM storage should be enabled
	bool bEnableDomStorage = false;
	GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bEnableDomStorage"), bEnableDomStorage, GEngineIni);

	FIntPoint viewportSize = WebBrowserWindowPtr.Pin()->GetViewportSize();
	FPlatformMisc::LowLevelOutputDebugStringf(TEXT("SAndroidWebBrowserWidget::Construct viewport=%d x %d"), viewportSize.X, viewportSize.Y);

	JavaWebBrowser = MakeShared<FJavaAndroidWebBrowser, ESPMode::ThreadSafe>(false, FAndroidMisc::ShouldUseVulkan(), viewportSize.X, viewportSize.Y,
		reinterpret_cast<jlong>(this), !(UE_BUILD_SHIPPING || UE_BUILD_TEST), Args._UseTransparency, bEnableDomStorage, bShouldUseBitmapRender);

	TextureSamplePool = new FWebBrowserTextureSamplePool();
	WebBrowserTextureSamplesQueue = MakeShared<FWebBrowserTextureSampleQueue, ESPMode::ThreadSafe>();
	WebBrowserTexture = nullptr;
	WebBrowserMaterial = nullptr;
	WebBrowserBrush = nullptr;