# Load\_from\_url freezes the interface during download in Sketchup 2017 and 2016

**URL:** <https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610>\
**Category:** Ruby API\
**Created:** [September 10, 2018, 9:56pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610 "2018-09-10T21:56:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vitorbalbio](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/vitorbalbio/32/55647_2.png) [@vitorbalbio](https://forums.sketchup.com/u/vitorbalbio)\
**Post date:** [September 10, 2018, 9:56pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/1 "2018-09-10T21:56:59Z")

</div>

Hi!  
I’m trying to develop a plugin that download files from my custom server but i’m getting problems in Sketchup 2017 and 2016 using definitions.load\_from\_url

Here’s a sample code:

```
def self.downloadModel()
        url = 'http://myserver.com/a.skp'
        mod = Sketchup::active_model
        cdef = mod.definitions.load_from_url(url)
        return unless cdef
        Sketchup.active_model.place_component(cdef)
    end

```

And here is the behavior:  
Sketchup 2018 - Software keeps responsible during download and freezes during import (OK)  
Sketchup 2017 - Software is irresponsible during download and import (BAD)  
Sketchup 2016 - Software is irresponsible during download and import (BAD)

Usually if you don’t try to do things in the software after the download ends it get back but is very common random crashes when you try to interact with the interface during the download/import of the file in 2016 and 2017.

So how can i get models from web in Sketchup 2016 and 2017 without freezes the interface during the download?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [September 12, 2018, 3:50pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/2 "2018-09-12T15:50:38Z")

</div>

Hmm… strange. We didn’t do anything to the API of the method for SU2018…  
Maybe there were some other changes in our core related to downloads that changed this. I would have to dig into the source history.

> [@vitorbalbio](#):
>
> Usually if you don’t try to do things in the software after the download ends it get back but is very common random crashes when you try to interact with the interface during the download/import of the file in 2016 and 2017.

Are you able to reliably reproduce this? Have you submitted the BugSplats? (Did you enter any information we can use to look up these crashes?)

> [@vitorbalbio](#):
>
> So how can i get models from web in Sketchup 2016 and 2017 without freezes the interface during the download?

For SU2017+ you could use the `Sketchup::Http::Request` class to perform a non-blocking download: [Class: Sketchup::Http::Request — SketchUp Ruby API Documentation](http://ruby.sketchup.com/Sketchup/Http/Request.html)

For SU2016 I’m not sure. Ruby threads isn’t working properly within SketchUp. Something about it being hosted into a desktop application and how Ruby’s treads are all managed by Ruby makes it misbehaves. So you cannot use a Ruby thread to perform a download with `Net::Http` in the background I’m afraid. (And you’d have SSL issues if you tried to connect to an HTTPS connection because of issues with OpenSSL in those versions.)

---

<div class="post-metadata">

**Author:** ![TIG](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tig/32/198_2.png) [@TIG](https://forums.sketchup.com/u/TIG)\
**Post date:** [September 12, 2018, 4:01pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/3 "2018-09-12T16:01:17Z")

</div>

_definition = model.definitions.load\_from\_url(url, **load\_handler** )_

How/where do you set up the **load\_handler** Class ?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [September 12, 2018, 4:05pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/4 "2018-09-12T16:05:04Z")

</div>

> [@TIG](#):
>
> How/where do you set up the **load\_handler** Class ?

It’s optional.

…hmm… now I’m starting wonder if using that would make it async… (Been a while since I used that method…)

---

<div class="post-metadata">

**Author:** ![vitorbalbio](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/vitorbalbio/32/55647_2.png) [@vitorbalbio](https://forums.sketchup.com/u/vitorbalbio)\
**Post date:** [September 13, 2018, 12:52pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/5 "2018-09-13T12:52:12Z")

</div>

> Are you able to reliably reproduce this?

Not really, it’s quite random but it occurs very frequently.

> For SU2017+ you could use the `Sketchup::Http::Request` class to perform a non-blocking download

Thanks will check about it.

> How/where do you set up the **load\_handler** Class ?

I already tried with and without the loader\_handler using the progress method to send updates to the plugin but the result is the same. it works in the 2018 and freezes in 2017 e 2016

If you guys any other ideas how can i produce non blocking downloads inside SU2017 and 2016 please let me know.

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [September 14, 2018, 11:14am UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/6 "2018-09-14T11:14:22Z")

</div>

> [@vitorbalbio](#):
>
> Not really, it’s quite random but it occurs very frequently.

Can you make sure to submit the bugsplat. Then give me nudge, with what SU version and platform - along with some keyboard in the report I can use to look it up in the database.

> [@vitorbalbio](#):
>
> If you guys any other ideas how can i produce non blocking downloads inside SU2017 and 2016 please let me know.

I had a look at the source to to refresh my memory. The download is synchronous only I’m afraid. So you’d have to provide your own download mechanism. As I mentioned, for SU2017 you could use `Sketchup::Http`. But for SU2016 is more complicated. You could look into make a Ruby C Extension and use a C/C++ library to perform the download async. We got example project on GitHub: [GitHub - SketchUp/ruby-c-extension-examples: Ruby C extension examples](https://github.com/SketchUp/ruby-c-extension-examples)

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [September 14, 2018, 11:16am UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/7 "2018-09-14T11:16:55Z")

</div>

> [@vitorbalbio](#):
>
> Sketchup 2018 - Software keeps responsible during download and freezes during import (OK)

Hmm… this sounds odd. The code that download is synchronous - the logic that load the downloaded SKP file into the model executes on the next line - there is no callback here internally. So I’m surprised and puzzled to hear that you find SketchUp to be responsive while it downloads. Can you interact with it? (The viewport, menus etc?)

---

<div class="post-metadata">

**Author:** ![vitorbalbio](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/vitorbalbio/32/55647_2.png) [@vitorbalbio](https://forums.sketchup.com/u/vitorbalbio)\
**Post date:** [September 14, 2018, 12:19pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/8 "2018-09-14T12:19:48Z")

</div>

> You could look into make a Ruby C Extension and use a C/C++ library to perform the download async.

Thanks i will take a look on it

> Can you interact with it? (The viewport, menus etc?)

Sure. in SU2018 i do. I’m disappointed to know that it’s a bug not a feature.  
I’m using windows 10 if that means something.

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [September 20, 2018, 8:54pm UTC](https://forums.sketchup.com/t/load-from-url-freezes-the-interface-during-download-in-sketchup-2017-and-2016/76610/9 "2018-09-20T20:54:54Z")

</div>

> [@vitorbalbio](#):
>
> Sure. in SU2018 i do. I’m disappointed to know that it’s a bug not a feature.

You can file feature requests and bug reports in our GitHub reporter. This would be a good one.

> **[Issues · SketchUp/api-issue-tracker](https://github.com/SketchUp/api-issue-tracker/issues)**
>
> Public issue tracker for the SketchUp and LayOut's APIs - Issues · SketchUp/api-issue-tracker
