try to 'garbage collect' after refreshing tile img src
This commit is contained in:
parent
28505c1040
commit
f80722c187
1 changed files with 6 additions and 5 deletions
|
|
@ -69,18 +69,19 @@ class App(
|
||||||
val imgSrc = img.src.substringBeforeLast('?')
|
val imgSrc = img.src.substringBeforeLast('?')
|
||||||
println("fetching $imgSrc")
|
println("fetching $imgSrc")
|
||||||
|
|
||||||
val newImg = Image()
|
var newImg : Image? = Image()
|
||||||
|
|
||||||
newImg.onload = {
|
newImg!!.onload = {
|
||||||
|
|
||||||
window.requestAnimationFrame {
|
window.requestAnimationFrame {
|
||||||
println("image loaded ${newImg.src}")
|
println("image loaded ${newImg!!.src}")
|
||||||
img.setAttribute("dynamic-reload", "true")
|
img.setAttribute("dynamic-reload", "true")
|
||||||
img.src = newImg.src
|
img.src = newImg!!.src
|
||||||
|
newImg = null // try to encourage garbage collection
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newImg.src = imgSrc //+ "?t=${currentTimeMillis()}"
|
newImg!!.src = imgSrc //+ "?t=${currentTimeMillis()}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue