Bug 181723 - REGRESSION (iOS 11.2.2): Unhandled Promise Rejection: Error: Out of executable memory in function at index
Summary: REGRESSION (iOS 11.2.2): Unhandled Promise Rejection: Error: Out of executabl...
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebAssembly (show other bugs)
Version: Safari 11
Hardware: iPhone / iPad iOS 11
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-01-17 03:07 PST by shader.yang
Modified: 2020-01-15 17:38 PST (History)
13 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shader.yang 2018-01-17 03:07:50 PST
Steps:
1. open Safari on iOS 11.2.2/11.2.5 beta5
2. access link: https://www.mujigame.com/games/muji/ws22

Expected:
The page can be opened and wasm runs well.

Actual:
Get Unhandled Promise Rejection: Error: Out of executable memory in function at index exception.

More information:
This issue is also found on wkwebview on iOS 11.2.2/11.2.5 beta5

And the same discussion can be referred to:
https://forum.unity.com/threads/webassembly-no-longer-working-on-ios-11-2-2.511905/
https://github.com/kripken/emscripten/issues/6042
Comment 1 Keith Miller 2018-03-27 02:19:09 PDT
This issue is likely because we generate more code in our changes to mitigate Spectre and run out of executable memory. There isn't a quick solution to this on our end, unfortunately.
Comment 2 shader.yang 2018-03-29 06:12:21 PDT
(In reply to Keith Miller from comment #1)
> This issue is likely because we generate more code in our changes to
> mitigate Spectre and run out of executable memory. There isn't a quick
> solution to this on our end, unfortunately.

Got it, thanks!
Comment 3 shader.yang 2018-03-29 07:06:50 PDT
(In reply to Keith Miller from comment #1)
> This issue is likely because we generate more code in our changes to
> mitigate Spectre and run out of executable memory. There isn't a quick
> solution to this on our end, unfortunately.

And more question, do you know whether this issue https://bugs.webkit.org/show_bug.cgi?id=183101 is related to Spectre patch too?

Thanks!
Comment 4 morten.sorvig 2018-09-28 00:53:53 PDT
Would it be possible to increase the size of the executable memory pool for iOS devices?

The code in ExecutableAllocator.cpp suggests a current size of 64MB for ARM64:

#if defined(FIXED_EXECUTABLE_MEMORY_POOL_SIZE_IN_MB) && FIXED_EXECUTABLE_MEMORY_POOL_SIZE_IN_MB > 0
static const size_t fixedExecutableMemoryPoolSize = FIXED_EXECUTABLE_MEMORY_POOL_SIZE_IN_MB * 1024 * 1024;
#elif CPU(ARM)
static const size_t fixedExecutableMemoryPoolSize = 16 * 1024 * 1024;
#elif CPU(ARM64)
static const size_t fixedExecutableMemoryPoolSize = 64 * 1024 * 1024;
#elif CPU(X86_64)
static const size_t fixedExecutableMemoryPoolSize = 1024 * 1024 * 1024;
#else
static const size_t fixedExecutableMemoryPoolSize = 32 * 1024 * 1024;
#endif
Comment 5 Saam Barati 2018-09-30 11:40:37 PDT
Is this still an issue in iOS 12?

The link reported here doesn't seem to do anything anymore.
Comment 6 morten.sorvig 2018-10-01 05:03:19 PDT
I can still reproduce this on 12.0 (16A366), using this test case: 

https://msorvig.github.io/qt-webassembly-examples/slate/slate.html
Comment 7 Saam Barati 2018-10-14 21:04:33 PDT
We bumped the space to 128MB recently (in ToT WebKit). That will probably make this test case work. Marking as configuration changed for now.
Comment 8 Walter Stumpf 2018-10-22 09:05:35 PDT
Looks like the change was reverted: https://bugs.webkit.org/show_bug.cgi?id=190453

If you need a new test case, I've made one here: http://packages.kognito.com/Safari_iOS_WASM_Bug (this loads on Safari/Edge/Chrome/Firefox on the "Desktop platform" and Chrome/Firefox on the "Android Platform").
Comment 9 Walter Stumpf 2019-01-28 11:22:59 PST
Hello, iOS 12.2 has the configuration change this ticket references (https://bugs.webkit.org/show_bug.cgi?id=190453) that was hopefully going to resolve this issue, but unfortunately it still exists.  What are the next steps?  Can I provide you with any more information or test cases?
Comment 10 Konstantin Tokarev 2019-01-29 11:10:08 PST
Reopening because of report by Walter Stumpf above
Comment 11 Walter Stumpf 2019-01-29 13:21:32 PST
Okay apologies for not conducting a full review with iOS 12.2!  

So TLDR: I would rate this ticket as 99% resolved.  In some various use cases this exact error can still happen (e.g. loading our Unity wasm app, navigating to a new page, when navigating back to the original page our app will often trigger this error on second load).  But on a newly opened tab, our Unity app can consistently load.  I'd still rate the behavior on 11.2.1 as more robust, but I think we can still work with the current implementation in 12.2.  

I apologize again for the confusion.  Thanks again for the help, you've made every Unity webgl developer happy!
Comment 12 Saam Barati 2019-02-10 20:22:26 PST
This probably won't be fully resolved until we implement an interpreter. But it might be worth looking into if we could try to GC to delete old code before throwing this exception.
Comment 13 Radar WebKit Bug Importer 2019-02-10 20:23:44 PST
<rdar://problem/47954056>
Comment 14 Michal Markowski 2019-06-27 11:09:07 PDT
It seems that the issue came back with the new iPadOS update. I checked few pages which worked on iOS 12 and they throw "Error: Out of executable memory in function at index" exceptionon on iPadOS 13 beta 2.
Comment 15 Walter Stumpf 2019-08-12 09:59:05 PDT
I can confirm on iPad OS (beta 6) this bug is back. :(  I have not tried iOS 13 on my iPhone yet, but on a fresh tab our wasm application (Unity game) cannot load on my iPad Pro.
Comment 16 Alexey Proskuryakov 2019-08-13 09:17:21 PDT
Please file new bugs with repro steps for the regressions seen in iOS 13 beta. An old bug that isn't fully resolved shouldn't be conflated with cases that used to work, but no longer do.
Comment 17 Walter Stumpf 2019-08-13 13:04:47 PDT
No worries I made one here: https://bugs.webkit.org/show_bug.cgi?id=200686
Comment 18 jujjyl 2019-12-16 09:03:16 PST
Running Unity content

http://clb.confined.space/dump/WebGL1-2019-12-11/

on Safari 12.1.1 on iPad Pro 2018 on iOS 12.3.1 works ok, but running the same page on Safari 13.0.3 on iPhone Xs on iOS 13.2.0 runs out of memory.

The communication trail at https://bugs.webkit.org/show_bug.cgi?id=200686 and https://bugs.webkit.org/show_bug.cgi?id=200807 suggests this bug would be fixed, though testing above page suggests that is not the case.