HTML5 Cannot enlarge memory arrays

HTML5 build always crash if add this:

UE_LOG(LogTemp, Warning, TEXT(“Тест”));

or any utf text

Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 1342177280, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 

uncaught exception: abort("Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 1342177280, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 ") at jsStackTrace@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:18997
stackTrace@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:19168
abort@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:1022946
abortOnCannotGrowMemory@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:21045
_sbrk@http://localhost:8000//HTML5_UTF.html:38613163:1
_malloc@http://localhost:8000//HTML5_UTF.html:38459714:1
__ZN4FMsg13Logf_InternalEPKciRK5FNameN13ELogVerbosity4TypeEPKwz [FMsg::Logf_Internal(char const*, int, FName const&, ELogVerbosity::Type, wchar_t const*, ...)]@http://localhost:8000//HTML5_UTF.html:922361:1
__ZN19AHTML5_UTFCharacter11MoveForwardEf [AHTML5_UTFCharacter::MoveForward(float)]@http://localhost:8000//HTML5_UTF.html:784133:1
__ZN21TMemberFunctionCallerI19AHTML5_UTFCharacterMS0_FvfEEclIJRfEEEDTclpmdtdefpT3ObjdtdefpT9MemFunPtrspcl7ForwardIT_Efp_EEEDpOS6_@http://localhost:8000//HTML5_UTF.html:790337:1
__ZNK16UE4Tuple_Private10TTupleImplI16TIntegerSequenceIjJEEJEE10ApplyAfterI21TMemberFunctionCallerI19AHTML5_UTFCharacterMS6_FvfEEJRfEEEDcOT_DpOT0_@http://localhost:8000//HTML5_UTF.html:790259:1
__ZNK34TBaseUObjectMethodDelegateInstanceILb0E19AHTML5_UTFCharacterF12TTypeWrapperIvEfEJEE7ExecuteEf [TBaseUObjectMethodDelegateInstance<false, AHTML5_UTFCharacter, TTypeWrapper<void> (float)>::Execute(float) const]@http://localhost:8000//HTML5_UTF.html:790210:1
__ZNK28FInputGestureUnifiedDelegate7ExecuteEf [FInputGestureUnifiedDelegate::Execute(float) const]@http://localhost:8000//HTML5_UTF.html:10330987:1
__ZN12UPlayerInput17ProcessInputStackERK6TArrayIP15UInputComponent17FDefaultAllocatorEfb [UPlayerInput::ProcessInputStack(TArray<UInputComponent*, FDefaultAllocator> const&, float, bool)]@http://localhost:8000//HTML5_UTF.html:10323655:1
__ZN17APlayerController18ProcessPlayerInputEfb [APlayerController::ProcessPlayerInput(float, bool)]@http://localhost:8000//HTML5_UTF.html:8886423:1
__ZN17APlayerController15TickPlayerInputEfb [APlayerController::TickPlayerInput(float, bool)]@http://localhost:8000//HTML5_UTF.html:10441467:1
__ZN17APlayerController10PlayerTickEf [APlayerController::PlayerTick(float)]@http://localhost:8000//HTML5_UTF.html:8874988:1
__ZN17APlayerController9TickActorEf10ELevelTickR18FActorTickFunction [APlayerController::TickActor(float, ELevelTick, FActorTickFunction&)]@http://localhost:8000//HTML5_UTF.html:8847942:1
__ZN18FActorTickFunction11ExecuteTickEf10ELevelTickN13ENamedThreads4TypeERK12TRefCountPtrI11FGraphEventE [FActorTickFunction::ExecuteTick(float, ELevelTick, ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&)]@http://localhost:8000//HTML5_UTF.html:4897440:1
__ZN17FTickFunctionTask6DoTaskEN13ENamedThreads4TypeERK12TRefCountPtrI11FGraphEventE [FTickFunctionTask::DoTask(ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&)]@http://localhost:8000//HTML5_UTF.html:4644528:1
__ZN10TGraphTaskI17FTickFunctionTaskE11ExecuteTaskER6TArrayIP14FBaseGraphTask17FDefaultAllocatorEN13ENamedThreads4TypeE [TGraphTask<FTickFunctionTask>::ExecuteTask(TArray<FBaseGraphTask*, FDefaultAllocator>&, ENamedThreads::Type)]@http://localhost:8000//HTML5_UTF.html:4643898:1
__ZN16FNamedTaskThread23ProcessTasksNamedThreadEib [FNamedTaskThread::ProcessTasksNamedThread(int, bool)]@http://localhost:8000//HTML5_UTF.html:2069636:1
__ZN16FNamedTaskThread21ProcessTasksUntilQuitEi [FNamedTaskThread::ProcessTasksUntilQuit(int)]@http://localhost:8000//HTML5_UTF.html:2067215:1
__ZN24FTaskGraphImplementation31ProcessThreadUntilRequestReturnEN13ENamedThreads4TypeE [FTaskGraphImplementation::ProcessThreadUntilRequestReturn(ENamedThreads::Type)]@http://localhost:8000//HTML5_UTF.html:2076421:1
__ZN24FTaskGraphImplementation22WaitUntilTasksCompleteERK6TArrayI12TRefCountPtrI11FGraphEventE16TInlineAllocatorILj4E17FDefaultAllocatorEEN13ENamedThreads4TypeE [FTaskGraphImplementation::WaitUntilTasksComplete(TArray<TRefCountPtr<FGraphEvent>, TInlineAllocator<4u, FDefaultAllocator> > const&, ENamedThreads::Type)]@http://localhost:8000//HTML5_UTF.html:2077042:1
__ZN18FTickTaskSequencer16ReleaseTickGroupE13ETickingGroupb [FTickTaskSequencer::ReleaseTickGroup(ETickingGroup, bool)]@http://localhost:8000//HTML5_UTF.html:4633338:1
__ZN16FTickTaskManager12RunTickGroupE13ETickingGroupb [FTickTaskManager::RunTickGroup(ETickingGroup, bool)]@http://localhost:8000//HTML5_UTF.html:4627489:1
__ZN6UWorld12RunTickGroupE13ETickingGroupb [UWorld::RunTickGroup(ETickingGroup, bool)]@http://localhost:8000//HTML5_UTF.html:15416508:1
__ZN6UWorld4TickE10ELevelTickf [UWorld::Tick(ELevelTick, float)]@http://localhost:8000//HTML5_UTF.html:15375045:1
__ZN11UGameEngine4TickEfb [UGameEngine::Tick(float, bool)]@http://localhost:8000//HTML5_UTF.html:15265683:1
__ZN11FEngineLoop4TickEv [FEngineLoop::Tick()]@http://localhost:8000//HTML5_UTF.html:830301:1
__Z10HTML5_Tickv [HTML5_Tick()]@http://localhost:8000//HTML5_UTF.html:868771:1
dynCall_v@http://localhost:8000//HTML5_UTF.html:38616394:1
Module.dynCall_v@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:972015
browserIterationFunc@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:116441
runIter@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:119552
Browser_mainLoop_runner@blob:http://localhost:8000/2d919216-9b26-4180-ac8b-61c15bc8d09e:1:117978

This kind of crash looks familiar. I believe this was something that was a “double bug” in both UE4 and Emscripten, with UE4 not expecting default locale of Emscripten being what it was, and triggering an infinite memory reallocation loop that would crash like that.

This change default_lang_is_utf8 by juj · Pull Request #5500 · emscripten-core/emscripten · GitHub should fix it, but I think UE4 has not yet migrated to use that version. You could try finding this line default_lang_is_utf8 by juj · Pull Request #5500 · emscripten-core/emscripten · GitHub in your generated .js export, and changing it as shown to see if that fixes it. If not, then it’s possible that there was something related to this that was being fixed in Emscripten, so once UE4 updates to a newer version of Emscripten, it’s possible that this will get fixed.

I am also having this issue. Thanks for the insight @juj. Unfortunately changing the LANG ENV var inside the exported .js from “C” to “C.UTF-8” didn’t change anything and I’m still getting the
Uncaught abort("Cannot enlarge memory arrays.
message in 4.21.1 Has anything else been changed since January that you’re aware of? Any workarounds for a project with this issue?

Did you try this?
https://forums.unrealengine.com/development-discussion/html5-development/78152-html5-uncaught-abort-cannot-enlarge-memory-arrays