Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
107 stars 83 forks source link

Advanced minification properties documentation #5831

Closed WilsonPercival closed 2 years ago

WilsonPercival commented 2 years ago

Problem description

I noticed that if the object name starts with a number, then it will not be obfuscated after advanced minification. Then we can use quotes and use advanced minification:

runtime.objects["0Sprite"]

Attach a .c3p

project: advanced_minification_properties_documentation.zip

export with advanced minification: New project.zip

Steps to reproduce

  1. Open the project and export it to the Web (HTML5) with advanced minification or take a ready-made archive with export.
  2. Upload it to the hosting.
  3. Open it.
  4. Open the console.

Observed result

aaa

I was able to get an object named 0Sprite, but not one named Sprite0.

Expected result

I didn't find any mention of this in the documentation. I think it would be nice to add it there. We don't have a way to use string object names and advanced minification anymore, do we?

https://www.construct.net/en/make-games/manuals/construct-3/scripting/guides/advanced-minification

More details

Affected browsers/platforms: Chrome

First affected release: broke in r300b

System details

View details Platform information Product: Construct 3 r300 (beta) Browser: Chrome 102.0.5005.115 Browser engine: Chromium Context: browser Operating system: Windows NT 0.1.0 Device type: desktop Device pixel ratio: 1 Logical CPU cores: 2 Approx. device memory: 4 GB User agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36 Language setting: en-US Local storage Storage quota (approx): 59 gb Storage usage (approx): 231 mb (0.4%) Persistant storage: No Browser support notes This list contains missing features that are not required, but could improve performance or user experience if supported. UI effects are disabled in settings. WebGL 2+ is not supported. Rendering quality and features may be affected. WebGL information Version string: WebGL 1.0 (OpenGL ES 2.0 Chromium) Numeric version: 1 Supports NPOT textures: partial Supports GPU profiling: no Supports highp precision: yes Vendor: Google Inc. (Intel) Renderer: ANGLE (Intel, Intel(R) HD Graphics Direct3D9Ex vs_3_0 ps_3_0, igdumdim64.dll) Major performance caveat: no Maximum texture size: 8192 Point size range: 1 to 256 Extensions: ANGLE_instanced_arrays EXT_blend_minmax EXT_color_buffer_half_float EXT_float_blend EXT_frag_depth EXT_shader_texture_lod EXT_texture_filter_anisotropic WEBKIT_EXT_texture_filter_anisotropic EXT_sRGB KHR_parallel_shader_compile OES_element_index_uint OES_standard_derivatives OES_texture_float OES_texture_float_linear OES_texture_half_float OES_texture_half_float_linear OES_vertex_array_object WEBGL_color_buffer_float WEBGL_compressed_texture_s3tc WEBKIT_WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_depth_texture WEBKIT_WEBGL_depth_texture WEBGL_lose_context WEBKIT_WEBGL_lose_context WEBGL_multi_draw Audio information System sample rate: 48000 Hz Output channels: 2 Output interpretation: speakers Supported decode formats: WebM Opus (audio/webm; codecs=opus) Ogg Opus (audio/ogg; codecs=opus) WebM Vorbis (audio/webm; codecs=vorbis) Ogg Vorbis (audio/ogg; codecs=vorbis) MPEG-4 AAC (audio/mp4; codecs=mp4a.40.5) MP3 (audio/mpeg) FLAC (audio/flac) PCM WAV (audio/wav; codecs=1) Supported encode formats: WebM Opus (audio/webm; codecs=opus) Video information Supported decode formats: WebM AV1 (video/webm; codecs=av01.0.00M.08) MP4 AV1 (video/mp4; codecs=av01.0.00M.08) WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8) Ogg Theora (video/ogg; codecs=theora) H.264 (video/mp4; codecs=avc1.42E01E) Supported encode formats: WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8)
AshleyScirra commented 2 years ago

The reason for this is 0Sprite is not a valid JavaScript identifier, so it's not possible to refer to it as a dot property (runtime.objects.0Sprite is invalid syntax). It can only be referred to as a string property, e.g. runtime.objects["0Sprite"], and the minifier does not change string properties, so it follows that the name "0Sprite" will not be changed. I can see how that might not be immediately obvious though, so I added a note under "Object and variable names from Construct" explaining that.