amplify-swift icon indicating copy to clipboard operation
amplify-swift copied to clipboard

Remove dependency on starscream in favor of URLSession

Open pokryfka opened this issue 3 years ago • 6 comments

Starting from iOS13 URLSession supports web sockets.

Please consider removing dependency on starscream

pokryfka avatar Nov 08 '21 15:11 pokryfka

I second this request, for a minor reason:

  • I need the AWS Amplify SDK, and use it via SPM
  • AWS Amplify SDK depends on this package (aws-appsync-realtime-client-ios)
  • This package depends on starscream up to the next minor version from 3.3.1
  • That currently depends on swift-nio-zlib-support which is deprecated. This leads to a warning in my Xcode project that I can't suppress:
ignoring declared target(s) 'swift-nio-zlib-support' in the system package

At a minimum, perhaps it could be updated to the latest version of starscream which no longer depends on swift-nio-zlib-support, unless running on Linux.

jgale avatar Nov 09 '21 00:11 jgale

Hi @pokryfka and @jgale , we've upgraded to Starscream 4.0.4 and it removes swift-nio-zlib-support. I believe Starscream is building native websocket support as well. From what I can tell, Starscream will use native websockets with a conditional version check for iOS 13 in the future. This seems to make the migration to native websockets less compelling.

AWS Amplify SDK depends on this package (aws-appsync-realtime-client-ios)

This is true regardless of which plugins are used and is due to the Amplify library being a monorepo. I believe this can be fixed in the future if we move the API plugin (the only plugin that uses this package) to its own repo, and is impacting customers which aren't using DataStore/API at all, and still have to pull in the dependency.

We're open to this discussion and would like to ask, are there more reasons to migrate off of Starscream or additional details for the consideration to use native websockets directly?

lawmicha avatar Apr 15 '22 14:04 lawmicha

Thanks for the detailed reply @lawmicha. Now that it's been upgraded to Starscream 4.0.4, my swift-nio-zlib-support warning is gone so I am happy. Thank you!

I can't speak to @pokryfka 's opinions, I don't have any knowledge or experience with the different websockets libraries.

jgale avatar Apr 15 '22 15:04 jgale

Hi @pokryfka and @jgale , we've upgraded to Starscream 4.0.4 and it removes swift-nio-zlib-support. I believe Starscream is building native websocket support as well. From what I can tell, Starscream will use native websockets with a conditional version check for iOS 13 in the future. This seems to make the migration to native websockets less compelling.

AWS Amplify SDK depends on this package (aws-appsync-realtime-client-ios)

This is true regardless of which plugins are used and is due to the Amplify library being a monorepo. I believe this can be fixed in the future if we move the API plugin (the only plugin that uses this package) to its own repo, and is impacting customers which aren't using DataStore/API at all, and still have to pull in the dependency.

We're open to this discussion and would like to ask, are there more reasons to migrate off of Starscream or additional details for the consideration to use native websockets directly?

Starscream using native websockets is one more reason to remove dependency on Starscream.

That is as long as you drop support for iOS12 and earlier.

Personally, with iOS16 (beta) to be announced in 1.5 months, I think requiring iOS13 and later is reasonable; especially that it bring a lot of language changes which would make AppSync API more modern and much more convenient to use; I mean Combine and async/await with async functions and sequences (the latter was formally introduced in iOS15 but we have backward compatibility in Swift back to iOS13).

pokryfka avatar Apr 19 '22 09:04 pokryfka

Any chance to have it done? :-D

This is a major change and requires proper testing but the actual code change should be simple as you abstracted WSS client in AppSyncWebsocketProvider.

Other than reducing dependencies, it improves compatibility with other libraries and tools. For example I use Proxyman for debugging network calls but AppSync subscription messages are not recorded as you use 3rd party library for networking.

pokryfka avatar Jan 25 '23 05:01 pokryfka

Please note aws-amplify/aws-appsync-realtime-client-ios#90

pokryfka avatar Jan 25 '23 05:01 pokryfka