Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on Android ,File Class use [seek] function ,need so long time!!!! #58872

Open
CoderMzx opened this issue Mar 7, 2022 · 9 comments
Open

on Android ,File Class use [seek] function ,need so long time!!!! #58872

CoderMzx opened this issue Mar 7, 2022 · 9 comments

Comments

@CoderMzx
Copy link

CoderMzx commented Mar 7, 2022

Godot version

3.4.3

System information

Android

Issue description

i build a Android Project,
my Game need to read bin File,
if i use File class and use seek function, the function is need so long time, my game is no response.

Steps to reproduce

Build Android Project, use File class to read binFile,
var _fp = File.new()
_fp.open("xxxx",Read)
_fp.seek(5000) <---- need so long time

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented Mar 7, 2022

@CoderMzx Please upload a minimal reproduction project to make this easier to troubleshoot.

@CoderMzx
Copy link
Author

CoderMzx commented Mar 8, 2022

@CoderMzx请上传一个最小的复制项目,以便更容易排除故障。

on PC build, is no problem.
but on Mobile build, the code runing time need 10s or a long time.
ps: you need to copy a bigFile on you temp project,

func _readFile():
	print("read begin   "+str(OS.get_unix_time()))          #  read begin  1646707209
	var f:File = File.new()
	f.open("res://bigFile",File.READ)
	for i in range(100):
		var offsets = int(rand_range(512,46137340))
		f.seek(offsets)
	print("read end    "+str(OS.get_unix_time()))            #  read begin  1646707221

@CoderMzx
Copy link
Author

CoderMzx commented Mar 8, 2022

@CoderMzx Please upload a minimal reproduction project to make this easier to troubleshoot.

I found the reason why the seek function took too long.

I try to download the file to the user folder of the mobile terminal, and then use the file class to read it. In this case, the seek function has no delay

Once binary resources are separated from PCK, the efficiency of seek will return to normal

If binary resources are packaged into PCK files, it will take 0.1 ~ 0.3 seconds to seek forward

@CoderMzx CoderMzx changed the title on Android ,File Class use [seek] function ,need so long timg!!!! on Android ,File Class use [seek] function ,need so long time!!!! Mar 8, 2022
@CoderMzx
Copy link
Author

CoderMzx commented Mar 8, 2022

I solved the problem by reading from the user folder. I hope this is caused by my usage rule error, but please add this special usage to the official documentation. Hopefully this will help Godot develop better on mobile. Otherwise, the Godot engine is very misleading to beginners

@ondesic
Copy link

ondesic commented Jul 30, 2022

I wonder if this is related to #62546. @CoderMzx Try it again with the latest Release Candidate 8

@akien-mga
Copy link
Member

CC @m4gr3d

@m4gr3d
Copy link
Contributor

m4gr3d commented Aug 1, 2022

I wonder if this is related to #62546. @CoderMzx Try it again with the latest Release Candidate 8

I don't think they're related since this was in 3.4.3, while the scoped storage update was only introduced for the 3.5 branch.

Once binary resources are separated from PCK, the efficiency of seek will return to normal

This implies this is tied to the performance of the pck format on Android for large projects. The Tesla engineers ran into a similar performance issue a while back, so this may be something worth looking into to see if we can improve.

@CoderMzx Which version of Android are you running on.

@m4gr3d
Copy link
Contributor

m4gr3d commented Aug 1, 2022

@akien-mga @reduz Are there docs describing the pck format?

@Calinou
Copy link
Member

Calinou commented Aug 1, 2022

Are there docs describing the pck format?

I don't remember seeing a specification for the PCK format, but https://github.com/bruvzg/gdsdecomp may have some reverse engineering notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants