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

UPnP Incompatibility with iOS 17.x+ #19246

Open
2 of 5 tasks
yzsnes opened this issue Jun 4, 2024 · 26 comments
Open
2 of 5 tasks

UPnP Incompatibility with iOS 17.x+ #19246

yzsnes opened this issue Jun 4, 2024 · 26 comments

Comments

@yzsnes
Copy link

yzsnes commented Jun 4, 2024

Game or games this happens in

None

What area of the game / PPSSPP

Attempting to enable UPnP under networking settings will give a "Unable to find UPnP device" error regardless if the router has UPnP enabled or not.

What should happen

The application should be able to detect the router as a UPnP device and allow for online play

Logs

No response

Platform

iOS

Mobile device model or graphics card (GPU)

iPhone 15

PPSSPP version affected

v1.17.1-491-g9cdd97c13b

Last working version

No response

Graphics backend (3D API)

Vulkan

Checklist

  • Test in the latest git build in case it's already fixed.
  • Search for other reports of the same issue.
  • Try resetting settings or older versions and include if the issue is related.
  • Try without any cheats and without loading any save states.
  • Include logs or screenshots of issue.
@hrydgard
Copy link
Owner

hrydgard commented Jun 4, 2024

Same issue, it seems:

https://forums.ppsspp.org/showthread.php?tid=29904

@anr2me
Copy link
Collaborator

anr2me commented Jun 4, 2024

May be try to update the miniupnp repo, there might be new commits there

hrydgard added a commit that referenced this issue Jun 4, 2024
Maybe will help #19246, but no idea really.
@hrydgard
Copy link
Owner

hrydgard commented Jun 4, 2024

A lot of new commits actually. Can someone test the PR? #19249

hrydgard added a commit that referenced this issue Jun 4, 2024
Maybe will help #19246, but no idea really.

Windows buildfix

UWP buildfix

miniupnpc path fixes

libretro buildfix attempt, android.mk
@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

Here is the iOS IPA artifact (for testing) generated after that PR https://github.com/hrydgard/ppsspp/actions/runs/9375693751/artifacts/1568951264

@yzsnes
Copy link
Author

yzsnes commented Jun 5, 2024

No luck! UPnP seems to work on my desktop but is still giving me an error on the test build.

Screenshot 2024-06-04 at 8 47 56 PM

Something else that was mentioned in forum threads discussing the issue was the UPnP timeout, which might be a factor here. Worth mentioning is that the app does request permission to view devices on the local network.

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

Did you gave the permission? because UPnP use SDDP (Simple Device Discovery Protocol) through UDP port 1900 to detect UPnP-compatible devices as i remembered.

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

May be similar issue to this https://superuser.com/questions/1512639/upnp-server-behind-firewall-wont-show-up-in-ios-apps

I'm in the middle of setting up a server net at home. The firewall between user and server net does UPnP-Routing via smcroute (and firewalling with iptables plus ipset). All in all it works perfectly. On my PCs and on my Android phone the media server (minidlna) gets found an serves the media files without question. Only the iOS devices (iPad and iPhone) make trouble. VLC recognizes the server here too, but the iOS version doesn't support resuming to an earlier timestamp after stopping the video. And two other apps don't find the server (in particular XtremePlayer which would be the first choice).

Something related to TTL ? not sure how to change that programmatically (may be using setsockopt with IP_TTL as parameter), especially since we don't have access to the miniupnp's socket, but the default TTL on iOS is 64 i think, so shouldn't be an issue (unless it's changed recently on newer iOS)

Finally with help from another forum I was able to identify the cause of this malfunction. The players that won't find the server send request packets with a TTL of 1 on the IP layer. Hence they aren't routable at all... The functioning ones (e.g. VLC) use higher values for TTL (in the case of VLC: 4). So, albeit I'm not able to fix this for good now I'm glad to know what's going on.

But it's old issue from 2019, so not sure.

@yzsnes
Copy link
Author

yzsnes commented Jun 5, 2024

Yes, I gave PPSSPP access to the local network. There's one or two posts I've seen of people able to use multiplayer, and a guide from about 2 or 3 months ago on how to connect to the soccom.cc servers using a modified IPA and specific add-on;

https://youtu.be/yvMXzTuwnvE?si=o1n3VAT_-L2LqWov

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

Yes, I gave PPSSPP access to the local network. There's one or two posts I've seen of people able to use multiplayer, and a guide from about 2 or 3 months ago on how to connect to the soccom.cc servers using a modified IPA and specific add-on;

https://youtu.be/yvMXzTuwnvE?si=o1n3VAT_-L2LqWov

Is that version still have working UPnP on your test? because it's only modified to support infrastructure i think, and the add-on you mean is the infra_plugin, right?

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

Btw the PR that expose UPnP timeout in networking settings is here #18867
But it was tested before and reported not to have a difference (although it uses an older version of miniupnp library during the test)

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

This might also be related (Multicast Networking entitlement issue?) https://forums.developer.apple.com/forums/thread/661606

However, I'm concerned about the app currently in production on the App Store, and how it behaves on various versions of iOS. Especially, it seems our app (built with Xcode 11) is still able to send multicast requests even if run on an iOS 14 device. However the app built with Xcode 12 systematically fails to send requests on the local network (through CFSocketSendData) on the same iOS 14 device, the local network access being properly granted by the user.

May be we need to add the com.apple.developer.networking.multicast key in the Info.plist file, like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.developer.networking.multicast</key>
	<true/>
</dict>
<dict/>
</plist>

But the Info.plist file inside the IPA seems to have a different content than the one in source code, was it auto-generated?

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

@yzsnes try this IPA. i only modified the Info.plist inside the IPA from the artifact above https://www.dropbox.com/scl/fi/lj97osa8ubq4zc8qcdukb/PPSSPP-iOS.zip?rlkey=jwr9j5x2wgnfy8bwvgfvx1zbn&st=ormahmcl&dl=0

PS: because i edited the file on Windows, the Info.plist attributes became different than it was, so not sure whether the new attribute will be accepted by iOS or not.
image

Edit: oops i put the com.apple.developer.networking.multicast key at the wrong location, reuploading the zip now.

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

Okay, here is iOS artifacts with com.apple.developer.networking.multicast included in it's Info.plist generated from this branch/PR ANR2MERefork#12 so there won't be file attribute issue here

iOS artifact: https://github.com/ANR2MERefork/ppsspp/actions/runs/9378116947/artifacts/1569463815

@Halo-Michael
Copy link
Contributor

Halo-Michael commented Jun 5, 2024

Okay, here is iOS artifacts with com.apple.developer.networking.multicast included in it's Info.plist generated from this branch/PR ANR2MERefork#12 so there won't be file attribute issue here

iOS artifact: https://github.com/ANR2MERefork/ppsspp/actions/runs/9378116947/artifacts/1569463815

Entitlements should bundle into code sign, not in Info.plist, see also: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_multicast?changes=l__9&language=objc
This entitlements only allowed request by "Apple Developer". Which means sideload users signing without an "paid Apple Developer Account" can't get this work. AppStore users not affected because you have already paid for that.
But you do need add a local network desciption (NSLocalNetworkUsageDescription) in Info.plist for upload to AppStore:
1f5c62f0bad105053b3eff5051d6d0c6
See also:
https://developer.apple.com/documentation/bundleresources/information_property_list/nslocalnetworkusagedescription?language=objc
C23A9C7C-1A22-4359-A4EE-BF4CCC01E675
It's requested in iOS14.0+.
cc @hrydgard

@hrydgard
Copy link
Owner

hrydgard commented Jun 5, 2024

Oh! I'll make sure to add that for the next update.

@hrydgard hrydgard added this to the v1.18.0 milestone Jun 5, 2024
@hrydgard hrydgard mentioned this issue Jun 5, 2024
20 tasks
@hrydgard
Copy link
Owner

hrydgard commented Jun 5, 2024

Oh right, I have to ask Apple for the entitlement too. Will do, hopefully they'll accept.

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

Is this mean only PPSSPP Gold users will be able to detects UPnP properly?
It will make debugging app that use broadcast/multicast became difficult isn't? (since debug builds will most-likely being sideloaded)

@hrydgard
Copy link
Owner

hrydgard commented Jun 5, 2024

I've put in requests for both the free version and the gold version (both App Store versions).

As for sideloaded builds, I don't know how to solve that.

@Halo-Michael
Copy link
Contributor

Is this mean only PPSSPP Gold users will be able to detects UPnP properly? It will make debugging app that use broadcast/multicast became difficult isn't? (since debug builds will most-likely being sideloaded)

...No
You are pay for Apple, not for PPSSPP

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

You mean as long the App ID is the same one with the one having the entitlement provisioned it will also works when sideloaded?

@Halo-Michael
Copy link
Contributor

You mean as long the App ID is the same one with the one having the entitlement provisioned it will also works when sideloaded?

Yes

@Halo-Michael
Copy link
Contributor

Halo-Michael commented Jun 5, 2024

1b0f3d26a0957bf1adb3f4d9349eab9b
How about unity the style?
cc @hrydgard

@hrydgard
Copy link
Owner

hrydgard commented Jun 5, 2024

Hm, we don't use the same app ID, but could change the sideload versions' ID though.

OK, I'll move them together and make more similar.

@anr2me
Copy link
Collaborator

anr2me commented Jun 5, 2024

The com.apple.developer.networking.multicast also need to be added to Entitlements.plist too isn't? something like https://github.com/hrydgard/ppsspp/blob/master/macOS/Entitlements.plist

Edit: probably not, since adding it manually could cause signing issue according to this https://stackoverflow.com/questions/76591665/is-it-enough-to-add-entitlements-manually

The entitlement needs to be added to your provisioning profile in the Apple developer portal. You can't add the entitlement until Apple has approved it and made it available to add to your provisioning profile. If you add the entitlement manually to your entitlements plist then you will get a code signing failure because the entitlements file does not match the provisioning profile.

@Halo-Michael
Copy link
Contributor

The com.apple.developer.networking.multicast also need to be added to Entitlements.plist too isn't? something like https://github.com/hrydgard/ppsspp/blob/master/macOS/Entitlements.plist

Edit: probably not, since adding it manually could cause signing issue according to this https://stackoverflow.com/questions/76591665/is-it-enough-to-add-entitlements-manually

The entitlement needs to be added to your provisioning profile in the Apple developer portal. You can't add the entitlement until Apple has approved it and made it available to add to your provisioning profile. If you add the entitlement manually to your entitlements plist then you will get a code signing failure because the entitlements file does not match the provisioning profile.

Read this: #19246 (comment)
See also: https://developer.apple.com/documentation/bundleresources/entitlements?language=objc

@hrydgard
Copy link
Owner

hrydgard commented Jun 8, 2024

I got approval for both the App Store versions to use multicast. So, hopefully it'll start working after the next update, if it hasn't already? I'm not sure what else I need to do.

@hrydgard hrydgard modified the milestones: v1.18.0, Future-Prio Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants