question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong calculation for initial file size

See original GitHub issue

Bug

Expected Behavior

Given a gzipped file in url When loading the page Then the calculated file size is correct.

Given a cc.json file in url When loading the page Then the calculated file size is correct.

Actual Behavior

The calculated file size is always 13 for gzipped files and 15 for not gzipped files.

Steps to Reproduce the Problem

  1. copy app/codeCharta/assets to dist/webpack which is the static file server in dev mode
  2. run in dev mode (npm run dev)
  3. add a debugger to the calculation
  4. open in browser e.g. http://localhost:3000/?file=assets%2Fsample3.cc.json, http://localhost:3000/?file=assets%2Fsample2.cc.json&file=assets%2Fsample3.cc.json or http://localhost:3000?file=assets%2Foutput.cc.json.gz

Technical analysis

Calculated file size for gzipped files comes from response.body.toString().length . response.body is a blob in that case. Therefore response.body.toString() is always the string "[object Blob]" and its length is 13

Calculated file size for not gzipped files comes from response.body.toString().length . response.body is an object in that case. Therefore response.body.toString() is always the string "[object Object]" and its length is 15

Note that previous urlExtractor.spec.ts mocked the http get request falsely as below. Therefore some tests had a different file size. But in reality initially it receives always a blob or an object. Also note that this complete parsing gets only called for initial map loading. Manual uploading a map doesn’t utilize the urlExtractor.

$http.get = jest.fn().mockImplementation(async () => {
			return { data: '{"checksum": "fake-md5", "data": {"apiVersion": 1.3, "nodes": []}}', status: 200 }
		})

Open question

Do we need the calculation, when it currently is a “random small hardcoded number” and no one has noticed?

What is actually the correct calculation? Should it be the length of (unzipped) text content of file? It seems to be used for map size resolution somehow? (see getMapResolutionScaleFactor within codeMapHelper.ts.

Specifications

  • is released in online-demo: yes
  • CodeCharta Version: 1.109.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
BridgeARcommented, Nov 24, 2022

Seems like this is unblocked now? 🎉

1reaction
ce-bocommented, Nov 3, 2022

We need the correct file size to handle the visualization of big maps and to avoid crashes of CC due to performance issues. Hence, it should be fixed.

In more detail: We try to scale down the resolution of the rendered city map according to the map size to prevent rendered maps with a resolution, for instance, of 50.000 x 50.000 pixels.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Enter a numeric value for the initial page file size" Error ...
I enter a initial size to the recomended size, and then a max size click on set and the problem begins. A system...
Read more >
C++ : Incorrect File Size Calculation WinAPI - Stack Overflow
What you need to do is expand at least one part of the expression ( ( FindFileData.nFileSizeHigh * ( MAXDWORD + 1 )...
Read more >
How is default page-file size actually calculated by Windows?
I want to know how does Windows calculate default page file size. For example, for 48 GB RAM it shows 7168 MB page...
Read more >
Is Your Virtual Memory Too Low? Here's How to Fix It!
Manually increasing the size of your paging file will alleviate this message, as per the error message. Windows sets the initial virtual ...
Read more >
Out of memory errors - set your pagefile
If you receive an out of memory error, you may need to increase your page file size for Windows on the fastest drive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found