Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
107 stars 83 forks source link

PlayableAds iOS Sound Toggler Issue (Unity Ads, Applovin) #5480

Closed vulegend closed 2 years ago

vulegend commented 2 years ago

Problem description

The single page html built by construct doesn't behave properly when interacting with iOS sound toggler on many ad networks. It completely ignores the sound off/on and there's no API provided to catch these events or interact with the sound toggler inside construct (or i haven't found any after extensive search).

Attach a .c3p

The cp3 file zip : unity_ads_sound_issue.zip And here's the link where the ad is hosted : https://vulegend.github.io/playable_solitaire/

Steps to reproduce

  1. Download unity Ad Testing tool
  2. Go to "Playable Tester" section of the Ad Testing app and insert the following as Playable URL: https://vulegend.github.io/playable_solitaire/
  3. Press Initialize than Show Ad
  4. Tap once to start the bit where the sound is played
  5. Switch the physical iOS sound toggler on/off

Or if you want to avoid using the Ad Testing tool for unity

  1. On your iphone go to your browser and navigate to https://vulegend.github.io/playable_solitaire/
  2. Tap once to start the bit where the sound is played
  3. Switch the physical iOS sound toggler on/off

Observed result

Currently the ad completely ignores the system off/on (the physical sound toggler on iOS).

Expected result

When the sound toggler is set to "silent" it should silence the ad, just like it does with any other application on the iOS. When it's turned back to regular mode, the sound should continue

More details

Worth noting that when using the "dapi" library for ironsource and hooking to their audio change listeners we are able to successfully mute and unmute the sound with the iOS toggler. However, this is only supported on ironsource and not on other ad networks

System details

View details Platform information Browser: Chrome Browser version: 98.0.4758.82 Browser engine: Chromium Context: webapp Operating system: Windows Operating system version: 10 Device type: desktop Device pixel ratio: 1 Logical CPU cores: 16 Approx. device memory: 8 GB User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36 C3 release: r276.2 (stable) Language setting: en-US Local storage Storage quota (approx): 558 gb Storage usage (approx): 104 mb (0%) Persistant storage: No Browser support notes This list contains missing features that are not required, but could improve performance or user experience if supported. Nothing is missing. Everything is OK! WebGL information Version string: WebGL 2.0 (OpenGL ES 3.0 Chromium) Numeric version: 2 Supports NPOT textures: yes Supports GPU profiling: yes Supports highp precision: yes Vendor: Google Inc. (NVIDIA) Renderer: ANGLE (NVIDIA, NVIDIA GeForce RTX 2080 Ti Direct3D11 vs_5_0 ps_5_0, D3D11-30.0.14.9709) Major performance caveat: no Maximum texture size: 16384 Point size range: 1 to 1024 Extensions: EXT_color_buffer_float EXT_color_buffer_half_float EXT_disjoint_timer_query_webgl2 EXT_float_blend EXT_texture_compression_bptc EXT_texture_compression_rgtc EXT_texture_filter_anisotropic EXT_texture_norm16 KHR_parallel_shader_compile OES_texture_float_linear WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_lose_context WEBGL_multi_draw OVR_multiview2 Audio information System sample rate: 48000 Hz Output channels: 2 Output interpretation: speakers Supported decode formats: WebM Opus (audio/webm; codecs=opus) Ogg Opus (audio/ogg; codecs=opus) WebM Vorbis (audio/webm; codecs=vorbis) Ogg Vorbis (audio/ogg; codecs=vorbis) MPEG-4 AAC (audio/mp4; codecs=mp4a.40.5) MP3 (audio/mpeg) FLAC (audio/flac) PCM WAV (audio/wav; codecs=1) Supported encode formats: WebM Opus (audio/webm; codecs=opus) Video information Supported decode formats: WebM AV1 (video/webm; codecs=av01.0.00M.08) MP4 AV1 (video/mp4; codecs=av01.0.00M.08) WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8) Ogg Theora (video/ogg; codecs=theora) H.264 (video/mp4; codecs=avc1.42E01E) Supported encode formats: WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8)
AshleyScirra commented 2 years ago

The provided project is very complicated. Please provide a minimal project as per the bug report guidelines.

Also, are you sure this is a problem with Construct? Isn't it up to the iOS system to make sure all apps go silent when changing the silent toggle? Does the ad service documentation say content are supposed to handle this themselves? If so can you link to the documentation where this is specified?

vulegend commented 2 years ago

@AshleyScirra I'll create a new project when i get back home, but this is applicable to any project. You can do a very simple project with only a sound source and it still won't respect it.

Well that's the issue that i found here - iOS developer guidelines put the responsibility on the implementation side, saying that the implementation should take care of the sound toggling. On the other hand, everywhere i encountered this issue on construct forums they were told that iOS system is handling this.

I believe construct is handling the sound using the Web Audio API and this is simply not enough to handle this case apparently - even unity ad tester shows a warning saying "Audio handled using Web Audio API only"

I've seen implementation in Phaser for example that use howler.js to handle this and it works without any issues.

AshleyScirra commented 2 years ago

As far as I'm aware, web content cannot detect the state of a system-level mute switch. It's part of the OS. And that means it's the OS's job to mute the sound output of applications. So I'm not sure why this falls to Construct, or even the ad network, to implement.

IIRC we had some past bug reports along the lines of "iOS silent mode doesn't mute all audio", but that appeared to be due to the design of iOS itself: some categories of sounds are still allowed to be played in silent mode, for whatever reason. However once again web content is not in control of the sound category that it counts as under iOS. That can possibly be specified at the WKWebView level or the ad network level or the app level, but those are all out of scope of what can be accessed from web content, so not something we could implement in Construct.

Perhaps the ad networks add their own APIs to detect the silent mode switch, but then I'd have to ask... why doesn't the app or OS do it? Web content does not normally have to worry about this.

AshleyScirra commented 2 years ago

This has been open for about 2 weeks but it's not clear the responsibility for dealing with this actually lies with Construct. I suspect the app, ad network, or OS ought to deal with it instead. I'd suggest following up with the relevant ad networks. If you can identify a specific change that Construct needs to make we can consider it, but as it stands it's not clear what changes we ought to make if any, so closing this issue.