Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Godot iOS fix: Asmjs support #31383

Closed
wants to merge 1 commit into from

Conversation

Mellondill
Copy link

This PR is needed for all iOS HTML5 build to work well, tested on iPhone 6s, 8, iPad 2015, in browsers: Safari and Chrome. Current implementation works well.
First 5 commits were done by @kroltan, I just wanted to initiate the PR due to @kroltan doesn't have time to do it. Last commit provided in current PR is needed for the HTML5 build to do not give the error of, that engine couldn't find the pkg file. If more detailed information is needed, I can provide it by request.

@Mellondill Mellondill requested a review from akien-mga as a code owner August 15, 2019 06:07
@Chaosus
Copy link
Member

Chaosus commented Aug 18, 2019

@kroltan
Copy link

kroltan commented Aug 18, 2019

Hi! Thanks for the PR. I'd like to note again as I mentioned on the issue that this current implementation has a very important issue: in asm.js iOS, sound playback is unsufferably distorted. At least on the devices we had for testing, which was the iPhone X and some form of iPad (don't remember which model at this moment).

Due to this issue I would be hesitant to call iOS a supported platform, at least without sufficient clarification in documentation on this limitation. But even then, for a large amount of games sound might be an essential feature.

Ideally someone with more knowledge of the engine's workings might be able to figure the problem before merging into a release.

@Mellondill
Copy link
Author

You need to squash the commits together (see http://docs.godotengine.org/en/latest/community/contributing/pr_workflow.html#mastering-the-pr-workflow-the-rebase)

Thanks, I'll do it today!

@Mellondill
Copy link
Author

Hi! Thanks for the PR. I'd like to note again as I mentioned on the issue that this current implementation has a very important issue: in asm.js iOS, sound playback is unsufferably distorted. At least on the devices we had for testing, which was the iPhone X and some form of iPad (don't remember which model at this moment).

Due to this issue I would be hesitant to call iOS a supported platform, at least without sufficient clarification in documentation on this limitation. But even then, for a large amount of games sound might be an essential feature.

Ideally someone with more knowledge of the engine's workings might be able to figure the problem before merging into a release.

Hi @kroltan, Thanks for the reply, I think this issue could happen because ogg sounds is not natively supported by iOS, but we will test sounds with wav format, and if it will works well, I think it could be acceptable. Besides, there is a library godot-minimp3 that could be helpful too. But in last case, we need to try to support GDNative for HTML5 build, and this issue could be already solved, we just need to test it

fix syntax error on wrapper code for asmjs module

updated web export to export both asmjs and wasm in a single build

remove extraneous file

expose wasm status to game

iOS Safari supported platform? godotengine#26554 - fixed
iPhone HTML5 export never loading godotengine#27019 - fixed

iOS Safari supported platform? godotengine#26554 - fixed
iPhone HTML5 export never loading godotengine#27019 - fixed

iOS Safari supported platform? godotengine#26554 - fixed
iPhone HTML5 export never loading godotengine#27019 - fixed

fixup! expose wasm status to game

fixup! expose wasm status to game

fixup! expose wasm status to game
@Mellondill
Copy link
Author

@Chaosus think that I've squashed all commits in one

@Mellondill
Copy link
Author

@Chaosus, @akien-mga
Hi guys,
Could you please tell if this PR could be proceeded, or may be there is something else that needed to be done for this PR to be approved?

Best regards,
Tony

@akien-mga
Copy link
Member

I don't understand why you want to reintroduce asm.js. It was deprecated as WebAssembly works much better, and is now supported by all browsers: https://caniuse.com/#feat=wasm

Reintroducing asm.js is not a good idea (as mentioned above, one unsolved problem is audio playback). If there are issues using WebAssembly on iOS Safari, they should be looked into and fixed - Safari claims Wasm support, so it should work or be fixed.

@scottkunkel
Copy link

I don't understand why you want to reintroduce asm.js. It was deprecated as WebAssembly works much better, and is now supported by all browsers: https://caniuse.com/#feat=wasm

Reintroducing asm.js is not a good idea (as mentioned above, one unsolved problem is audio playback). If there are issues using WebAssembly on iOS Safari, they should be looked into and fixed - Safari claims Wasm support, so it should work or be fixed.

Godot has been lacking in IOS HTML5 support for a long time for now. I'd see this as a stop gap until the actual wasm works in IOS browser, which I would not expect anytime soon.
Above solution only uses asm in IOS browser and wasm everywhere else so nothing else would get affected. Apart from the non-existing ogg support, which I would not expect working in wasm either, things look very good.

@akien-mga
Copy link
Member

Godot has been lacking in IOS HTML5 support for a long time for now.

What are the actual problems? Are there bug reports? Did anyone look into them? If Safari claims Wasm support, it should be possible to run Godot Wasm exports on Safari. If not, that's a bug and it needs to be fixed.

Apart from the non-existing ogg support, which I would not expect working in wasm either, things look very good.

Well OGG playback works fine in Wasm... There are tons of Godot games published with WebAssembly with sfx and music.

@scottkunkel
Copy link

Godot has been lacking in IOS HTML5 support for a long time for now.

What are the actual problems? Are there bug reports? Did anyone look into them? If Safari claims Wasm support, it should be possible to run Godot Wasm exports on Safari. If not, that's a bug and it needs to be fixed.

quick search:
https://github.com/godotengine/godot/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen++ios++html

#26554
#27019

The issue has been raised for over a year. I did not see anyone else working on this.

Apart from the non-existing ogg support, which I would not expect working in wasm either, things look very good.

Well OGG playback works fine in Wasm... There are tons of Godot games published with WebAssembly with sfx and music.

Ogg is not supported by Safari IOS:
https://caniuse.com/#search=ogg

@scottkunkel
Copy link

scottkunkel commented Nov 13, 2019

I don't understand why you want to reintroduce asm.js. It was deprecated as WebAssembly works much better, and is now supported by all browsers: https://caniuse.com/#feat=wasm

Reintroducing asm.js is not a good idea (as mentioned above, one unsolved problem is audio playback). If there are issues using WebAssembly on iOS Safari, they should be looked into and fixed - Safari claims Wasm support, so it should work or be fixed.

Let's look at it from a utility point: IOS HTML5 usage is currently broken. This solution does not affect any other HTML usage. It will allow HTML5 to play in IOS without ogg sound. That is much better than what we currently have.

This is an open source project. Debugging IOS Html errors is rather esoteric. So, the chances of someone fixing the wasm issues short term is basically 0.

So we can either have a somewhat working ios html for now or nothing for a long time to come.

@steffenkre
Copy link

Apple fixed the wasm issue on iOS 13. tested it on an iPhone, worked fine

@scottkunkel
Copy link

Apple fixed the wasm issue on iOS 13. tested it on an iPhone, worked fine

I can confirm it starts up but crashes very quickly in IOS using wasm. Cannot debug, though

@steffenkre
Copy link

steffenkre commented Nov 22, 2019

Apple fixed the wasm issue on iOS 13. tested it on an iPhone, worked fine

I can confirm it starts up but crashes very quickly in IOS using wasm. Cannot debug, though

have you tested different scnes/projects?

@akien-mga
Copy link
Member

As mentioned above, I don't want to reintroduce support for asm.js. WebAssembly is the way forward and works much better than our asm.js backend ever did.

WebAssembly issues on iOS Safari are unfortunate, but this is also one of the worst browsers on the market in terms of standard compliance. The fault is on Apple and you should be sure to file support tickets with Apple about it.

If anyone really wants to deploy a project for iOS HTML5 with asm.js, the code in this Pull Request can be merged manually for your custom builds. (You can retrieve it as a patch with https://github.com/godotengine/godot/pull/31383.patch.)

@scottkunkel
Copy link

I would agree with this now, that some wasm starts to work on IOS

@wisplite
Copy link

wisplite commented Jun 7, 2023

This might want to be looked at again. It’s been 3 1/2 years and this is still a problem. I can’t load a basic 2D game on iPadOS (every browser on iOS uses the same engine). The only reason I think this is something Godot should add a patch for is because Unity3D works perfectly fine on my iPad, it’s specifically Godot games that don’t launch, and it’s clear at this point Apple doesn’t care about making their browser function properly.

asm.js should be part of Godot 4 as an optional fallback, similar to how Godot 3 let you fallback to GLES2 if you had to.

Current version is iPadOS 16.5

@Calinou
Copy link
Member

Calinou commented Jun 7, 2023

@tbukfrc I'm not sure if going back to asm.js would resolve issues such as #67949 and #70621. Feel free to try on your end, but other issues such as audio playback may come back as mentioned above.

asm.js is no longer maintained these days, so we would essentially have to take maintenance for ourselves, especially as people on non-iOS platforms will be using asm.js if it's reimplemented. While you could export your project for both asm.js and WebAssembly, this is probably not something most people will bother doing. In this case, this means the only playable version of a web game would be accessible via asm.js, which is less efficient.

It could be possible to deploy asm.js as an automatic fallback by including both a WebAssembly and asm.js payload and choosing at load-time based on the current platform, but this can introduce difficult-to-debug issues.

Also, Godot 4.x's web export requires WebGL 2.0, which is usually the problem on iOS and some macOS browsers rather than WebAssembly itself. See godotengine/godot-proposals#10044.

@wisplite
Copy link

wisplite commented Jun 7, 2023

Ah, that’s unfortunate. Is there any way I can export my Godot 4 project in Godot 3 with GLES2 then, if that’s the main problem?

@Calinou
Copy link
Member

Calinou commented Jun 7, 2023

Ah, that’s unfortunate. Is there any way I can export my Godot 4 project in Godot 3 with GLES2 then, if that’s the main problem?

You would need to downgrade your project to Godot 3.x. Godot 4 has a built-in tool to convert Godot 3 projects to Godot 4, but no such tool exists for downgrading projects yet. It's not just a matter of performing replacements the other way around, as scene/resource files need to be saved in a way that restores numerical IDs as opposed to string UIDs.

@AThousandShips AThousandShips removed this from the 3.2 milestone Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants