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

Problems with very large images #105

Open
samth opened this issue Aug 24, 2020 · 8 comments
Open

Problems with very large images #105

samth opened this issue Aug 24, 2020 · 8 comments

Comments

@samth
Copy link
Sponsor Member

samth commented Aug 24, 2020

With a program with a very large image in it, DrRacket become extremely sluggish, and animate seems to show only a black square some of the time.

To reproduce, in Beginning Student:

(define airplane ...) ;; paste in this image https://image.cnbcfm.com/api/v1/image/106537227-1589463911434gettyimages-890234318.jpeg?v=1589463982
(require 2htdp/image)
(require 2htdp/universe)
(define plane (scale 0.05 airplane))
(image-height plane)
(define (go n) (place-image plane 200 n (empty-scene 400 400)))
(go 0)
(go 50)
(go 150)
(go 250)
(go 350)
(go 450)
(animate go)
@mfelleisen
Copy link
Contributor

mfelleisen commented Aug 24, 2020 via email

@mfelleisen
Copy link
Contributor

mfelleisen commented Aug 24, 2020 via email

@samth
Copy link
Sponsor Member Author

samth commented Aug 24, 2020

I eventually let things calm down enough to run my program, and got the behavior I described. I agree that there seem to be DrRacket-related issues as well (cc @rfindler).

This is Racket BC.

@mfelleisen
Copy link
Contributor

mfelleisen commented Aug 24, 2020 via email

@samth
Copy link
Sponsor Member Author

samth commented Aug 24, 2020 via email

@rfindler
Copy link
Member

This looks like one of those situations where it may turn out to be many separate things that need improving. It looks like one of them is saving the file. DrRacket does an autosave pretty quickly after the paste and it takes a long time. Here's some code that just does that part, demonstrating what's slow. I think the autosave timeout is shorter than the time that the saving takes, which compounds things significantly.

#lang racket/gui

(define t (new text%))
(printf "0\n")
(define bmp
  (time (make-object image-snip% "airplane.jpg")))
(printf "1\n")
(time (send t insert bmp))
(printf "2\n")
(time (send t save-file "airplane.rktd"))
(printf "3\n")

@rfindler
Copy link
Member

rfindler commented Sep 4, 2020

This commit is one piece of the puzzle (meant to note the connection in the commit message but forgot): racket/gui@e947d59

rfindler added a commit to racket/draw that referenced this issue Sep 7, 2020
rfindler added a commit to racket/typed-racket that referenced this issue Sep 7, 2020
rfindler added a commit to racket/snip that referenced this issue Sep 7, 2020
when constructing a bitmap from a file, to request that data be saved

related to racket/htdp#105
@rfindler
Copy link
Member

rfindler commented Sep 7, 2020

With the latest set of commits, the time it takes to call save-file in the code above goes from 12 seconds to 20ish msec. This matches the time to save in DrRacket when the airplane image is inserted via file|insert image, but when it is pasted in, I see about 5 seconds for the first time the file is saved and then 1ish seconds after that (because there isn't enough information in the paste data (at least that I know how to get) to take the very fastest path).

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

No branches or pull requests

3 participants