Please help me test my Instance Serializer by serializing a bunch of Instances and finding issues

I’m not sure if this is the right category to post this in, please let me know if I should post this somewhere else. The reason that this is in Scripting Support is well… I believe that it’s about getting support from people in scripting this Instance Serializer by asking everyone to help in hunting bugs, therefore it is in Scripting Support.

Minstance, an Instance Serializer, is in its very early stages of development, so I would greatly appreciate if people who are currently reading this could perhaps help in finding issues/bugs by serializing a bunch of Instances and letting me know of any issues that you may come across, such as a specific data type not being supported (which I believe would be common for you to come across, as I haven’t yet added support for other data types besides the ones that BufferEncoder already supports), etc.

This Instance Serializer aims to be the absolute best of the best in every aspect, such as serialized data compression ratio, serialization speed and more.


Performance

Currently, it can serialize the whole entire map of Classic Crossroads (1736 Instances) down to just a string with 33919 characters within just 0.04s, while compressing it takes 0.2s (mainly due to a bottleneck with the public zlib module being used, which will be greatly optimized in the future) while still preserving all of its properties.
image

Left - Original
Right - After serialization and deserialization


How it works

This works by firstly getting all of the accessible properties of an Instance (including all of its descendants) and mapping each one of them into one single table. This table is then encoded with BufferEncoder, then passed to this public zlib compression module which greatly compresses the data but comes with a significant performance hit. And if the EncodeInBase94 setting is enabled then it will be then encoded in base94 using a module I wrote, which is useful if you want to save the serialized data into DataStore.


Public resources used & changes done to them:

  1. GitHub - anexpia/BufferEncoder: A very efficient and simple-to-use encoder that turns tables into buffers - (BufferEncoder.Write) Fixed a bug where the allocate function relies on info.currentsize to decide if it needs to resize the buffer but the write function only ever updates its local cursor variable after each write. It used to never update info.currentsize, which means the allocate function always read an old info.currentsize (example: 0), adds the small amount it needs for the current write (example: 4), and incorrectly concludes that the total size (4) is less than the info.allocatedsize (example: 256). It decides not to resize the buffer, but the actual cursor is already near the end of the buffer, causing a buffer access out of bounds error to occur.
  2. String Compression (zlib/deflate) - Added --!native tag.
  3. MaximumADHD’s Mini API Dump - Used for gaining the properties of an Instance without using currently disabled ReflectionService methods.

Usage

Minstance.SerializeInstance(TargetInstance: Instance, SerializationSettings: {}) - Serializes an Instance. SerializationSettings format:

{
	--> Setting: ValueType = DefaultValue
	IncludeDescendants: boolean = true -- Self explanatory
	CompressSerializedData: boolean = true -- Compresses serialized data with zlib
	EncodeInBase94: boolean = false -- Encodes data in Base94, useful for saving data into DataStore
	AnnoyingConsolePrint: boolean = true -- Annoyingly throws console outputs like "[Minstance] Finished compressing serialized data in 0.0002s!"
}

Minstance.DeserializeInstance(DeserializedData: string, DeserializationSettings: {}) - Decompresses or deserializes data passed into it. Please note that you have to explicitly specify if your data is compressed, if it is encoded in Base94, etc. DeserializationSettings format:

{
	--> Setting: ValueType = DefaultValue
	IsDataCompressed: boolean = true,
	IsBase94Encoded: boolean = false,
	AnnoyingConsolePrints: boolean = true,
	ParentInstanceWhileDeserializing: Instance = nil -- The deserialized Instance will be parented to this Instance BEFORE it deserializes its children.
}

Example:


Get Minstance and help in hunting bugs!

EDIT: As of around 7 hours after making this post, I no longer need help from the community in testing, as I have found my own slaves to do it. Stay tuned for when this gets ready for release!

The issue you had there should be fixed now, It was actually due to a wrong number being used for calculating the size of enums and enumitems, rather than the reliance on info.currentsize over cursor variable.
image

Regardless, I switched allocate() - now named expandbuffertosize() - to using cursor as I found that info.currentsize wasn’t really necessary. Thanks for pointing this out.