René's URL Explorer Experiment


Title: Named Messages: Don't allocate a byte array whenever you send a message · Issue #2779 · Unity-Technologies/com.unity.netcode.gameobjects · GitHub

Open Graph Title: Named Messages: Don't allocate a byte array whenever you send a message · Issue #2779 · Unity-Technologies/com.unity.netcode.gameobjects

X Title: Named Messages: Don't allocate a byte array whenever you send a message · Issue #2779 · Unity-Technologies/com.unity.netcode.gameobjects

Description: Is your feature request related to a problem? Please describe. Named Messages are a great way to send custom messages that are not tied to a specific game object and/or are more dynamic than standard RPC calls. However, the only way to s...

Open Graph Description: Is your feature request related to a problem? Please describe. Named Messages are a great way to send custom messages that are not tied to a specific game object and/or are more dynamic than standa...

X Description: Is your feature request related to a problem? Please describe. Named Messages are a great way to send custom messages that are not tied to a specific game object and/or are more dynamic than standa...

Opengraph URL: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Named Messages: Don't allocate a byte array whenever you send a message","articleBody":"**Is your feature request related to a problem? Please describe.**\r\nNamed Messages are a great way to send custom messages that are not tied to a specific game object and/or are more dynamic than standard RPC calls. However, the only way to send these messages (via `CustomMessagingManager.SendNamedMessage`) is by providing a string which gets then hashed using `XXHash.Hash32` or `XXHash.Hash64` which then calls `Encoding.UTF8.GetBytes(text)`. This function always allocates a new byte array, containing the string. As far as I can see, there is no other possible way to send a named message.\r\n\r\n**Describe the solution you'd like**\r\nI see two possible solutions:\r\n* Don't use `Encoding.UTF8.GetBytes(text)` and instead use one of the overloads where you can specify an existing `byte[]` or Span. This would allow the use of a pre-alloced buffer (e.g. from a temp alloced NativeArray or an array pool).\r\n* Add a function overload where I can provide the hash myself (and provide a way to obtain this hash). This would work similar to e.g. `Animator.StringToHash` or `Shader.PropertyToID`. However, the HashSize can be 4 bytes or 8 bytes (depending on `NetworkManager.NetworkConfig.RpcHashSize`) and can even change during the runtime (at least, `CustomMessageManager` supports this case). Therefore it might be a bit confusing to the user which hash (with which data type) they have to use in this case - unless the `GetHash` function returns a struct which contains both hashes...which might be a bit weird as well.\r\n\r\n**Describe alternatives you've considered**\r\n* I can use unnamed messages and just re-implement the logic from named messages, using the solution described above.\r\n\r\n**Additional context**\r\n\r\nExample GC Alloc from the profiler:\r\n```\r\nSize: 41\r\n\r\nCall Stack:\r\nmscorlib.dll!System.Text::Encoding.GetBytes()\r\nUnity.Netcode.Runtime.dll!Unity.Netcode::XXHash.Hash32()\t./Library/PackageCache/com.unity.netcode.gameobjects@1.5.2/Runtime/Hashing/XXHash.cs:218\r\nUnity.Netcode.Runtime.dll!Unity.Netcode::CustomMessagingManager.SendNamedMessage()\t./Library/PackageCache/com.unity.netcode.gameobjects@1.5.2/Runtime/Messaging/CustomMessageManager.cs:296\r\nUnity.Netcode.Runtime.dll!Unity.Netcode::CustomMessagingManager.SendNamedMessageToAll()\t./Library/PackageCache/com.unity.netcode.gameobjects@1.5.2/Runtime/Messaging/CustomMessageManager.cs:236\r\n```\r\n\r\nI wouldn't say this is a huge problem (though it depends on how many messages are being sent and how long their name is), and unnamed messages are an easy workaround. However, most of this package seems to focus on allocating as little as possible, and I think that fixing this problem here shouldn't be too hard (otherwise just ignore this issue).\r\n\r\nThanks for your work on this amazing package, I really enjoy using it! I can also provide a PR with a fix mentioned above if you would like me to, I just didn't want to submit something unwanted.","author":{"url":"https://github.com/Valerionn","@type":"Person","name":"Valerionn"},"datePublished":"2023-11-28T05:02:47Z","url":"https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a9bbac6e-d649-ae82-b72f-785080bafb3e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBD4A:5537E:2675C18:3301772:6B0057EC
html-safe-noncead97d88774c4c9eefb28e449db9e24a746cd8554ab9eacfe0e2e20427a9b6607
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDRBOjU1MzdFOjI2NzVDMTg6MzMwMTc3Mjo2QjAwNTdFQyIsInZpc2l0b3JfaWQiOiI1MTgyMTg2MjI0NDc5MzM0MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac641f9264ee344db4c303e9f4761cda2035aab43ec7531d72a6e97be5d6506be1
hovercard-subject-tagissue:2013650055
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Unity-Technologies/com.unity.netcode.gameobjects/2779/issue_layout
twitter:imagehttps://opengraph.githubassets.com/99cbac00d18e41af4d0e27fc9992418da8b3e48c9edc5d237d61a5b0055d4586/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/99cbac00d18e41af4d0e27fc9992418da8b3e48c9edc5d237d61a5b0055d4586/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
og:image:altIs your feature request related to a problem? Please describe. Named Messages are a great way to send custom messages that are not tied to a specific game object and/or are more dynamic than standa...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameValerionn
hostnamegithub.com
expected-hostnamegithub.com
Nonef420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb
turbo-cache-controlno-preview
go-importgithub.com/Unity-Technologies/com.unity.netcode.gameobjects git https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git
octolytics-dimension-user_id426196
octolytics-dimension-user_loginUnity-Technologies
octolytics-dimension-repository_id116385203
octolytics-dimension-repository_nwoUnity-Technologies/com.unity.netcode.gameobjects
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id116385203
octolytics-dimension-repository_network_root_nwoUnity-Technologies/com.unity.netcode.gameobjects
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release26e00df917aba0f128135dc073ea0c5e33a70d40
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FUnity-Technologies%2Fcom.unity.netcode.gameobjects%2Fissues%2F2779
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FUnity-Technologies%2Fcom.unity.netcode.gameobjects%2Fissues%2F2779
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=Unity-Technologies%2Fcom.unity.netcode.gameobjects
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
Reloadhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
Unity-Technologieshttps://github.com/Unity-Technologies
com.unity.netcode.gameobjectshttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects
Codehttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects
Issues35 (35)https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues
Pull requests27 (27)https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pulls
Actionshttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/actions
Security and qualityhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/security
Insightshttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/insights
https://github.com/Unity-Technologies/com.unity.netcode.gameobjects
New issuehttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
New issuehttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
Named Messages: Don't allocate a byte array whenever you send a messagehttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779#top
type:featureNew feature, request or improvementhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Afeature%22
https://github.com/Valerionn
Valerionnhttps://github.com/Valerionn
on Nov 28, 2023https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779#issue-2013650055
Valerionnhttps://github.com/Valerionn
stat:awaiting-triageStatus - Awaiting triage from the Netcode team.https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aawaiting-triage%22
type:featureNew feature, request or improvementhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Afeature%22
on Nov 28, 2023https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779#event-11078830416
michalChrobothttps://github.com/michalChrobot
stat:reply-neededAwaiting reply from Unity accounthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Areply-needed%22
stat:awaiting-triageStatus - Awaiting triage from the Netcode team.https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Aawaiting-triage%22
on Apr 1, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779#event-17076812713
michalChrobothttps://github.com/michalChrobot
stat:reply-neededAwaiting reply from Unity accounthttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22stat%3Areply-needed%22
on Apr 11, 2025https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779#event-17230062890
Sign up for freehttps://github.com/signup?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
Sign in to commenthttps://github.com/login?return_to=https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2779
type:featureNew feature, request or improvementhttps://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues?q=state%3Aopen%20label%3A%22type%3Afeature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.