{"id":26988993,"url":"https://github.com/danesz/sidewalkexample","last_synced_at":"2026-04-18T00:32:06.537Z","repository":{"id":71811720,"uuid":"428042474","full_name":"Danesz/SidewalkExample","owner":"Danesz","description":"Sample code for WebSocket-based Javascript execution in WKWebview via Sidewalk Swift SDK.","archived":false,"fork":false,"pushed_at":"2021-11-14T22:39:30.000Z","size":47569,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T19:51:52.459Z","etag":null,"topics":["javascript","swift","webview","wkwebview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Danesz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-14T21:11:52.000Z","updated_at":"2021-11-14T22:44:49.000Z","dependencies_parsed_at":"2023-06-07T13:00:12.136Z","dependency_job_id":null,"html_url":"https://github.com/Danesz/SidewalkExample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Danesz/SidewalkExample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danesz%2FSidewalkExample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danesz%2FSidewalkExample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danesz%2FSidewalkExample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danesz%2FSidewalkExample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Danesz","download_url":"https://codeload.github.com/Danesz/SidewalkExample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danesz%2FSidewalkExample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31951291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","swift","webview","wkwebview"],"created_at":"2025-04-03T20:46:29.042Z","updated_at":"2026-04-18T00:32:06.517Z","avatar_url":"https://github.com/Danesz.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SidewalkExample\n\nSample code for WebSocket-based Javascript execution in WKWebview via [Sidewalk Swift SDK](https://github.com/Danesz/Sidewalk).\n\n\n## The project\nThe project showcases a workaround for a [memory leak in WKWebView](https://bugs.webkit.org/show_bug.cgi?id=215729) when using `evaluateJavaScript`\n\nThe webview keeps reference to the script that was executed via `evaluateJavaScript` even after the execution was finished.\n\nIn this example we send 1 MB strings in every 0,5 sec to the webview and ask to print the length of it.\n\n\n## The results\nThe script executions and their effect on the memory were investigated on a jailbroken iPhone with `htop`, `top` and `Xcode`\n\n### WKWebview.evaluateJavasSript(..)\nOnce the WKWebview was initialized, a new `com.apple.WebKit.WebContent` process appeared on the process list.\nThe memory usage of this process started to climb up rapidly, above **500+ MB**, more than 25% of the available memory of the device.\n\n(Sometimes, being on this level for a longer period, the webview seemed like it crashed. It got \"refreshed\" and loaded an empty `about:blank` page.)\n\n![evaluateJavaScript recording](WebviewEvalHighlight.gif)\n\n### sidewalkJavaScript(...)\nBy using the Sidewalk-way, the memory usage was around **87 MB**.\n\n![sidewalkJavaScript recording](SidewalkEvalHighlight.gif)\n\n### Conclusion\nIt seems for a Javascript-heavy WKWebview-based application the WebSocket approach is more suitable.\n\nAfter destorying the webview the memory will be freed, so continous re-creation is also an option when using `evaluateJavaScript`. If the goal is to have a long-living webview, some care is needed around Javascript execution. Here `Sidewalk` can come handy.\n\n## Disclaimer\nSidewalkExample and the Sidewalk projects are in a proof-of-concept phase, without any warranties, for educational purposes only.\nThe author will not be liable for any misinterpretation of data and damages you may suffer in connection with using, modifying, or distributing the projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanesz%2Fsidewalkexample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanesz%2Fsidewalkexample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanesz%2Fsidewalkexample/lists"}