Skip to content

Commit

Permalink
Merge pull request jupyter-widgets#3171 from joseph2rs/widget_image_f…
Browse files Browse the repository at this point in the history
…ix_revoke_object_url

fix: [Widget Image] Remove oldurl string check since it's always a string and prevent the ObjectURL cleaning resulting in a memory leak.
  • Loading branch information
jasongrout authored Mar 25, 2021
2 parents 8cf38cf + 1ca079e commit 24628f0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/controls/src/widget_audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class AudioView extends DOMWidgetView {
// Clean up the old objectURL
const oldurl = this.el.src;
this.el.src = url;
if (oldurl && typeof oldurl !== 'string') {
if (oldurl) {
URL.revokeObjectURL(oldurl);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/controls/src/widget_image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ export class ImageView extends DOMWidgetView {
// Clean up the old objectURL
const oldurl = this.el.src;
this.el.src = url;
if (oldurl && typeof oldurl !== 'string') {
if (oldurl) {
URL.revokeObjectURL(oldurl);
}

const width = this.model.get('width');
if (width !== undefined && width.length > 0) {
this.el.setAttribute('width', width);
Expand Down
2 changes: 1 addition & 1 deletion packages/controls/src/widget_video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class VideoView extends DOMWidgetView {
// Clean up the old objectURL
const oldurl = this.el.src;
this.el.src = url;
if (oldurl && typeof oldurl !== 'string') {
if (oldurl) {
URL.revokeObjectURL(oldurl);
}

Expand Down

0 comments on commit 24628f0

Please sign in to comment.