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

web: Fix extension not working in Safari 16 (close #10981) #19348

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

thy486
Copy link
Contributor

@thy486 thy486 commented Jan 26, 2025

If there are no other changes in Safari 16+, this PR will fix #10981

@thy486 thy486 force-pushed the fix-safari-extension branch from a661cf2 to e80b687 Compare January 27, 2025 16:37
@thy486 thy486 changed the title web: fix extension does not work in Safari 16 web: Fix extension does not work in Safari 16 Jan 27, 2025
@thy486 thy486 force-pushed the fix-safari-extension branch from e80b687 to 5010294 Compare January 28, 2025 00:04
@danielhjacobs danielhjacobs changed the title web: Fix extension does not work in Safari 16 web: Fix extension not working in Safari 16 Jan 28, 2025
@danielhjacobs danielhjacobs changed the title web: Fix extension not working in Safari 16 web: Fix extension not working in Safari 16 (close #10981) Jan 28, 2025
@thy486
Copy link
Contributor Author

thy486 commented Jan 29, 2025

It should be compatible with Safari 15 and earlier versions because I only added an additional way to get the ID. Safari current logic hides the content of the src field for scripts loaded by extensions, it is the root cause of the failure to get the ID,
further causes ruffle.ts to fail to send postMessage.

@danielhjacobs danielhjacobs added A-web Area: Web & Extensions extension Related to the Ruffle WebExtension T-fix Type: Bug fix (in something that's supposed to work already) labels Jan 30, 2025
@adrian17
Copy link
Collaborator

adrian17 commented Feb 6, 2025

Did you find any documentation about what exactly changed in 16? If yes, can you link it in comments; if not, can you document what's going on with safari?

@thy486
Copy link
Contributor Author

thy486 commented Feb 6, 2025

Did you find any documentation about what exactly changed in 16? If yes, can you link it in comments; if not, can you document what's going on with safari?

Sorry, I did not find any documentation related. But I can share with you how I debugged.

Just follow the steps below to reproduce the bug

  1. Set breakpoints in code like script.src = url and this.remove() snippets in content.js Screenshot  2025-02-06 16 32 25
  2. Print url and rewrite url to none id url (easier to set breakpoints) Screenshot  2025-02-06 16 24 08
  3. Set breakpoints in code like document.currentScript !== undefined snippet in ruffle.js Screenshot  2025-02-06 16 35 02
  4. Refresh page and repeat step 2. Briefly record the id in url
  5. Enter the breakpoint set in step 3 and then set breakpoint at code like ID = new URL(document.currentScript.src).searchParams.get("id"); snippet
  6. Enter the breakpoint. Hover on code document.currentScript.src or run code document.currentScript.src you can get value webkit-masked-url://hidden/ 截屏2025-02-07 05 19 21
  7. So of course ID is null value. It causes the bug Extension does not work in Safari 16 #10981
    Screenshot  2025-02-06 16 21 08

Follow the steps below to simply fix for this bug (based on the above steps)

  1. Rewrite ID to id recorded at above step 4
    Screenshot  2025-02-06 16 24 14

  2. The event listener is running correctly and postMessage will be run
    Screenshot  2025-02-06 16 21 53
    Screenshot  2025-02-06 17 07 53

  3. Successfully listened to the event sent by ruffle.js in content.js
    Screenshot  2025-02-06 17 14 51
    Screenshot  2025-02-06 17 15 01

You can verify this bug by restore document.currentScript.src to original url (The property document.currentScript.src can be modified successfully in the script that the user loads normally and does not trigger reload)

@danielhjacobs
Copy link
Contributor

Quick note, none of our devs have the ability to test this, but as it's a low-risk change we will merge it for you and others to test.

@danielhjacobs danielhjacobs enabled auto-merge (rebase) February 28, 2025 23:53
@danielhjacobs
Copy link
Contributor

Sorry for the long wait, we were hoping someone else would test it and report if it worked for them.

@danielhjacobs danielhjacobs merged commit eb3f657 into ruffle-rs:master Feb 28, 2025
20 checks passed
Hancock33 added a commit to Hancock33/batocera.piboy that referenced this pull request Mar 2, 2025
--------------------------------------------------------------------------------------------------------
batocera-emulationstation.mk e222233081ad86931deb1805a3387ca457d3151a # Version: Commits on Mar 01, 2025
--------------------------------------------------------------------------------------------------------
update po

Signed-off-by: Nicolas Adenis-Lamarre <nicolas.adenis.lamarre@gmail.com>,

------------------------------------------------------------------------------------------------
batocera-es-piboy.mk e222233081ad86931deb1805a3387ca457d3151a # Version: Commits on Mar 01, 2025
------------------------------------------------------------------------------------------------
update po

Signed-off-by: Nicolas Adenis-Lamarre <nicolas.adenis.lamarre@gmail.com>,

------------------------------------------------------------------------------------------
duckstation.mk 965da856db48664beddf82a88d5e3b5b5252f77a # Version: Commits on Mar 01, 2025
------------------------------------------------------------------------------------------
FullscreenUI: Add additional rounding to some dialogs,

--------------------------------------------------------------------------------------
flycast.mk 9e0573aa9880fe7abfde8830f5ee32db28c0c373 # Version: Commits on Feb 28, 2025
--------------------------------------------------------------------------------------
Fetch translations & Recreate libretro_core_options_intl.h,

----------------------------------------------------
pcsx2.mk v2.3.187 # Version: Commits on Mar 01, 2025
----------------------------------------------------
- [GameDB/Link: Fix validation limit for Half Pixel Offset](PCSX2/pcsx2#12373)

,

-----------------------------------------------------------------------------------
play.mk 43e373a54002578199c220e4a5a95603110b1d2d # Version: Commits on Feb 27, 2025
-----------------------------------------------------------------------------------
Implement GetModuleIdListByName.,

---------------------------------------------------------------
ruffle.mk nightly-2025-03-01 # Version: Commits on Mar 01, 2025
---------------------------------------------------------------
## What's Changed

* core: Remove unused last_text_control by @kjarosh in ruffle-rs/ruffle#19652

* frontend_utils: Be more verbose on IO bundle errors by @kjarosh in ruffle-rs/ruffle#19658

* core: Work toward removing static strings by @Lord-McSweeney in ruffle-rs/ruffle#19612

* desktop: Map window to movie position explicitly by @kjarosh in ruffle-rs/ruffle#19651

* avm1: Replace `GcCell` with `Gc` in AVM1 structs by @kjarosh in ruffle-rs/ruffle#19657

* web: Fix extension not working in Safari 16 (close #10981) by @thy486 in ruffle-rs/ruffle#19348

## New Contributors

* @thy486 made their first contribution in ruffle-rs/ruffle#19348

**Full Changelog**: ruffle-rs/ruffle@nightly-2025-02-28...nightly-2025-03-01,

--------------------------------------------------------------------------------------
shadps4.mk db868ea40076a981ac010b1f85e2503cbac526fb # Version: Commits on Feb 28, 2025
--------------------------------------------------------------------------------------
Fix: sce_sys/snd0.at9 remains after game deletion (#2565),

------------------------------------------------------------------------------------------
devilutionx.mk 8dc0f039f94be74a48cf08f5c16e78af8a00d18f # Version: Commits on Mar 01, 2025
------------------------------------------------------------------------------------------
Add a text rendering integration test

This shows that we still have some issues with draw string with colors +

kerning fit but that's OK as we don't use that currently.,

--------------------------------------------------------------------------------------
stalker.mk 8d12a8b565629e92b94d7ef98be033846007a488 # Version: Commits on Feb 28, 2025
--------------------------------------------------------------------------------------
Detect if localization.ltx was changed and use the updated language value

Before introducing a console command to change the language, mods used

to change localization.ltx. We now detect that and reselect the language

according to the updated localization.ltx file.

For example, this allows localization switch to work in Call of

Chernobyl (#1529),

----------------------------------------------------------------------------------------------------
sdl2-gamecontrollerdb.mk 773a1862d999e2bb53d70cc8826d59e8a21686f4 # Version: Commits on Mar 01, 2025
----------------------------------------------------------------------------------------------------
Sort,

----------------------------------------------------------------------------------------
retroarch.mk b3e2d5213da74b904f54d85bcf23f41cd33626ef # Version: Commits on Mar 01, 2025
----------------------------------------------------------------------------------------
Fetch translations from Crowdin,

-----------------------------------------------------------------------------------
tr1x.mk 3808fa7c28485ce22eae9c8e55b6743a81e1764a # Version: Commits on Mar 01, 2025
-----------------------------------------------------------------------------------
inventory: limit max item quantities to fix crashing (#2554)

Resolves #2497.,

-----------------------------------------------------------------------------------
tr2x.mk 3808fa7c28485ce22eae9c8e55b6743a81e1764a # Version: Commits on Mar 01, 2025
-----------------------------------------------------------------------------------
inventory: limit max item quantities to fix crashing (#2554)

Resolves #2497.,

------------------------------------------------------------------------------------------
xash3d-fwgs.mk 7222830b28eb61d81ac8197113c2a3eea4a18577 # Version: Commits on Feb 28, 2025
------------------------------------------------------------------------------------------
Documentation: supported-mod-list.md: a little remark.,

---------------------------------------------------------------------------------------------
libretro-fbneo.mk 74a979724da9a3c4c8986076123c3293861614c5 # Version: Commits on Mar 01, 2025
---------------------------------------------------------------------------------------------
(libretro) update files,

-----------------------------------------------------------------------------------------------
libretro-flycast.mk 9e0573aa9880fe7abfde8830f5ee32db28c0c373 # Version: Commits on Feb 28, 2025
-----------------------------------------------------------------------------------------------
Fetch translations & Recreate libretro_core_options_intl.h,

-----------------------------------------------------------------------------------------------------
libretro-mame2003-plus.mk 4893b3f74450814df1e1264c8a3a283afa59b835 # Version: Commits on Feb 28, 2025
-----------------------------------------------------------------------------------------------------
Merge pull request #1943 from carlosefr/mrdo_volume

Lower volume in Mr. Do! to avoid clipping,

--------------------------------------------------------------------------------------------
libretro-mgba.mk eeb52e40274a8240fe066a16b93d9d46c4b677b9 # Version: Commits on Jan 24, 2025
--------------------------------------------------------------------------------------------
libretro: change accelerometer values to be same as for switch,

--------------------------------------------------------------------------------------------
libretro-play.mk 43e373a54002578199c220e4a5a95603110b1d2d # Version: Commits on Feb 27, 2025
--------------------------------------------------------------------------------------------
Implement GetModuleIdListByName.,

---------------------------------------------------------------------------------------------
libretro-tic80.mk ce24179d53374d8bbf7d04808888d3cfd8d90c2f # Version: Commits on Mar 01, 2025
---------------------------------------------------------------------------------------------
Fix OPT_END() missing without BUILD_EDITORS flag (#2748),

---------------------------------------------------------------------------------------------
libretro-vba-m.mk c8a1d8eb2ef8fb825d95f956b62f3a2b62ca3bd6 # Version: Commits on Feb 28, 2025
---------------------------------------------------------------------------------------------
translations: transifex pull

Signed-off-by: Rafael Kitover <rkitover@gmail.com>,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web Area: Web & Extensions extension Related to the Ruffle WebExtension T-fix Type: Bug fix (in something that's supposed to work already)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extension does not work in Safari 16
3 participants